* fix junit test cases

* added module in parent build
This commit is contained in:
Amit Pandey 2020-08-17 10:30:19 +05:30 committed by GitHub
parent 2214774f55
commit 62432a2532
4 changed files with 7 additions and 4 deletions

View File

@ -31,6 +31,6 @@ public class UseDateTimeFormatterUnitTest {
public void givenALocalDate_whenFormattingWithStyleAndLocale_thenPass() {
String result = subject.formatWithStyleAndLocale(localDateTime, FormatStyle.MEDIUM, Locale.UK);
assertThat(result).isEqualTo("25 Jan 2015, 06:30:00");
assertThat(result).isEqualTo("25-Jan-2015 06:30:00");
}
}

View File

@ -3,6 +3,7 @@ package com.baeldung.datetime;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
@ -24,10 +25,11 @@ public class UseToInstantUnitTest {
@Test
public void givenADate_whenConvertingToLocalDate_thenAsExpected() {
Date givenDate = new Date(1465817690000L);
LocalDateTime currentDateTime = LocalDateTime.now();
Date givenDate = Date.from(currentDateTime.atZone(ZoneId.systemDefault()).toInstant());
LocalDateTime localDateTime = subject.convertDateToLocalDate(givenDate);
assertThat(localDateTime).isEqualTo("2016-06-13T13:34:50");
assertThat(localDateTime).isEqualTo(currentDateTime);
}
}

View File

@ -54,7 +54,7 @@ public class UseZonedDateTimeUnitTest {
@Test
public void givenAStringWithTimeZone_whenParsing_thenEqualsExpected() {
ZonedDateTime resultFromString = zonedDateTime.getZonedDateTimeUsingParseMethod("2015-05-03T10:15:30+01:00[Europe/Paris]");
ZonedDateTime resultFromLocalDateTime = ZonedDateTime.of(2015, 5, 3, 11, 15, 30, 0, ZoneId.of("Europe/Paris"));
ZonedDateTime resultFromLocalDateTime = ZonedDateTime.of(2015, 5, 3, 10, 15, 30, 0, ZoneId.of("Europe/Paris"));
assertThat(resultFromString.getZone()).isEqualTo(ZoneId.of("Europe/Paris"));
assertThat(resultFromLocalDateTime.getZone()).isEqualTo(ZoneId.of("Europe/Paris"));

View File

@ -64,6 +64,7 @@
<module>core-java-date-operations-2</module>
<!-- We haven't upgraded to java 9. -->
<!-- <module>core-java-datetime-computations</module> <module>core-java-datetime-conversion</module> <module>core-java-datetime-java8</module> <module>core-java-datetime-string</module> -->
<module>core-java-8-datetime</module>
<module>core-java-exceptions</module>
<module>core-java-exceptions-2</module>