#681 Using UTC for Date/JavaLocalDate conversion in both directions

This commit is contained in:
Gunnar Morling 2015-11-06 19:19:34 +01:00
parent 1f091c35e2
commit 18c03a328d
2 changed files with 3 additions and 5 deletions

View File

@ -33,6 +33,6 @@ public class JavaLocalDateTimeToDateConversion extends SimpleConversion {
@Override
protected String getFromExpression(ConversionContext conversionContext) {
return "java.time.LocalDateTime.ofInstant( <SOURCE>.toInstant(), java.time.ZoneId.systemDefault() )";
return "java.time.LocalDateTime.ofInstant( <SOURCE>.toInstant(), java.time.ZoneId.of( \"UTC\" ) )";
}
}

View File

@ -240,12 +240,12 @@ public class Java8TimeConversionTest {
source = SourceTargetMapper.INSTANCE.targetToSource( target );
assertThat( source.getForDateConversionWithZonedDateTime() ).isEqualTo( dateTime );
}
@Test
public void testLocalDateTimeToDateMapping() {
TimeZone.setDefault( TimeZone.getTimeZone( "UTC" ) );
TimeZone.setDefault( TimeZone.getTimeZone( "Australia/Melbourne" ) );
Source source = new Source();
LocalDateTime dateTime = LocalDateTime.of( 2014, 1, 1, 0, 0 );
source.setForDateConversionWithLocalDateTime( dateTime );
@ -266,7 +266,5 @@ public class Java8TimeConversionTest {
source = SourceTargetMapper.INSTANCE.targetToSource( target );
assertThat( source.getForDateConversionWithLocalDateTime() ).isEqualTo( dateTime );
}
}