Add unit tests for LocalDate to ISO 8601

This commit is contained in:
anujgaud 2023-11-18 00:27:03 +05:30 committed by GitHub
parent 52c96522c1
commit eaf6ce5fbe
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package com.baeldung.localDateToISO;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import java.time.LocalDate;
public class LocalDateToISOUnitTest {
@Test
public void givenLocalDate_whenUsingDateTimeFormatterThenISOFormat(){
LocalDateToISO localDateToISO = new LocalDateToISO();
LocalDate localDate = LocalDate.of(2023, 11, 6);
String expected = "2023-11-06T00:00:00Z";
String actual = localDateToISO.formatUsingDateTimeFormatter(localDate);
assertEquals(expected, actual);
}
@Test
public void givenLocalDate_whenUsingSimpleDateFormatThenISOFormat(){
LocalDateToISO localDateToISO = new LocalDateToISO();
LocalDate localDate = LocalDate.of(2023, 11, 6);
String expected = "2023-11-06T00:00:00Z";
String actual = localDateToISO.formatUsingSimpleDateFormat(localDate);
assertEquals(expected, actual);
}
}