use of org.joda.time.LocalTime in project mapstruct by mapstruct.
the class JodaConversionTest method testStringToLocalTime.
@ProcessorTest
public void testStringToLocalTime() {
String dateTimeAsString = "00:00";
Target target = new Target();
target.setLocalTime(dateTimeAsString);
LocalTime sourceTime = new LocalTime(0, 0);
Source src = SourceTargetMapper.INSTANCE.targetToSourceLocalTimeMapped(target);
assertThat(src).isNotNull();
assertThat(src.getLocalTime()).isEqualTo(sourceTime);
}
use of org.joda.time.LocalTime in project mapstruct by mapstruct.
the class JodaConversionTest method testLocalTimeToString.
@ProcessorTest
public void testLocalTimeToString() {
Source src = new Source();
src.setLocalTime(new LocalTime(0, 0));
Target target = SourceTargetMapper.INSTANCE.sourceToTargetLocalTimeMapped(src);
assertThat(target).isNotNull();
assertThat(target.getLocalTime()).isEqualTo("00:00");
}
use of org.joda.time.LocalTime in project mapstruct by mapstruct.
the class JodaConversionTest method testTargetToSourceMappingForStrings.
@ProcessorTest
public void testTargetToSourceMappingForStrings() {
Target target = new Target();
target.setDateTime("01.01.2014 00:00 UTC");
target.setLocalDateTime("01.01.2014 00:00");
target.setLocalDate("01.01.2014");
target.setLocalTime("00:00");
Source src = SourceTargetMapper.INSTANCE.targetToSource(target);
assertThat(src.getDateTime()).isEqualTo(new DateTime(2014, 1, 1, 0, 0, DateTimeZone.UTC));
assertThat(src.getLocalDateTime()).isEqualTo(new LocalDateTime(2014, 1, 1, 0, 0));
assertThat(src.getLocalDate()).isEqualTo(new LocalDate(2014, 1, 1));
assertThat(src.getLocalTime()).isEqualTo(new LocalTime(0, 0));
}
Aggregations