Search in sources :

Example 1 with UseLocalDateTime

use of com.baeldung.datetime.UseLocalDateTime in project tutorials by eugenp.

the class StringConversionUnitTest method whenConvertedToLocalDateTime_thenCorrect.

@Test
public void whenConvertedToLocalDateTime_thenCorrect() {
    String str = "2007-12-03T10:15:30";
    int afterConvCalendarDay = 03;
    Month afterConvCalendarMonth = Month.DECEMBER;
    int afterConvCalendarYear = 2007;
    LocalDateTime afterConvDate = new UseLocalDateTime().getLocalDateTimeUsingParseMethod(str);
    assertEquals(afterConvDate.getDayOfMonth(), afterConvCalendarDay);
    assertEquals(afterConvDate.getMonth(), afterConvCalendarMonth);
    assertEquals(afterConvDate.getYear(), afterConvCalendarYear);
}
Also used : UseLocalDateTime(com.baeldung.datetime.UseLocalDateTime) LocalDateTime(java.time.LocalDateTime) Month(java.time.Month) UseLocalDateTime(com.baeldung.datetime.UseLocalDateTime) Test(org.junit.Test)

Aggregations

UseLocalDateTime (com.baeldung.datetime.UseLocalDateTime)1 LocalDateTime (java.time.LocalDateTime)1 Month (java.time.Month)1 Test (org.junit.Test)1