1

I use maven to run unit and integration tests, and flyway migrations. My machine timezone is set to +2:00. How can override this so that all actions triggered by maven eg:

mvn flyway:migrate 

use UTC as the timezone?

ThatDataGuy
  • 1,969
  • 2
  • 17
  • 43

2 Answers2

0

You can configure the TimeZone on the pom.xml of your application when you configure your flyway plugin like this.

       <plugin>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-maven-plugin</artifactId>
            <version>6.0.4</version>
            <configuration>
                <user.timezone>UTC</user.timezone> //In case of Java 7 or
                <argLine>-Duser.timezone=UTC</argLine> //Incase of Java 8 and above. 
            </configuration>
        </plugin>

You can refer this answer for more details and this for details of Flyway maven configurations.

  • After doing this, it seems that the jdbc connection flyway is making is still picking up my local machine timezone, and the database interprets my datetime literals as being in +2:00 https://stackoverflow.com/questions/58285143/how-to-set-timezone-on-postgresql-jdbc-connection-created-by-flyway – ThatDataGuy Oct 08 '19 at 14:18
  • Some jdbc drivers need configuration in jdbc url. For eg, `jdbc:mysql://localhost:3306/db?useLegacyDatetimeCode=false&serverTimezone=UTC` – pmverma Oct 09 '19 at 08:00
0

A colleague suggested the following argument to the maven invocation

mvn <target> -Duser.timezone=UTC
ThatDataGuy
  • 1,969
  • 2
  • 17
  • 43