Search in sources :

Example 1 with YearMonth

use of org.joda.time.YearMonth in project serenity-jbehave by serenity-bdd.

the class WhenConvertingJodaDateTimes method should_detect_YearMonth_format_with_slash.

@Test
public void should_detect_YearMonth_format_with_slash() {
    YearMonthConverter converter = new YearMonthConverter();
    YearMonth convertedTime = (YearMonth) converter.convertValue("10/1942", YearMonth.class);
    assertThat(convertedTime.getMonthOfYear()).isEqualTo(10);
    assertThat(convertedTime.getYear()).isEqualTo(1942);
}
Also used : YearMonth(org.joda.time.YearMonth) Test(org.junit.Test)

Example 2 with YearMonth

use of org.joda.time.YearMonth in project joda-time-android by dlew.

the class TestDateUtils method testIsToday.

public void testIsToday() {
    LocalDate today = LocalDate.now();
    LocalDate yesterday = today.minusDays(1);
    LocalDate tomorrow = today.plusDays(1);
    assertEquals(true, DateUtils.isToday(today));
    assertEquals(false, DateUtils.isToday(yesterday));
    assertEquals(false, DateUtils.isToday(tomorrow));
    LocalDateTime todayLdt = LocalDateTime.now();
    LocalDateTime yesterdayLdt = todayLdt.minusDays(1);
    LocalDateTime tomorrowLdt = todayLdt.plusDays(1);
    assertEquals(true, DateUtils.isToday(todayLdt));
    assertEquals(false, DateUtils.isToday(yesterdayLdt));
    assertEquals(false, DateUtils.isToday(tomorrowLdt));
    DateTime todayDt = DateTime.now();
    DateTime yesterdayDt = todayDt.minusDays(1);
    DateTime tomorrowDt = todayDt.plusDays(1);
    assertEquals(true, DateUtils.isToday(todayDt));
    assertEquals(false, DateUtils.isToday(yesterdayDt));
    assertEquals(false, DateUtils.isToday(tomorrowDt));
    try {
        DateUtils.isToday(new MonthDay());
        fail("DateUtils.isToday() should have thrown an error since MonthDay has no year.");
    } catch (Exception e) {
    }
    try {
        DateUtils.isToday(new YearMonth());
        fail("DateUtils.isToday() should have thrown an error since YearMonth has no day.");
    } catch (Exception e) {
    }
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) YearMonth(org.joda.time.YearMonth) MonthDay(org.joda.time.MonthDay) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) LocalDateTime(org.joda.time.LocalDateTime)

Example 3 with YearMonth

use of org.joda.time.YearMonth in project serenity-jbehave by serenity-bdd.

the class WhenConvertingJodaDateTimes method should_detect_YearMonth_format.

@Test
public void should_detect_YearMonth_format() {
    YearMonthConverter converter = new YearMonthConverter();
    YearMonth convertedTime = (YearMonth) converter.convertValue("10-1942", YearMonth.class);
    assertThat(convertedTime.getMonthOfYear()).isEqualTo(10);
    assertThat(convertedTime.getYear()).isEqualTo(1942);
}
Also used : YearMonth(org.joda.time.YearMonth) Test(org.junit.Test)

Example 4 with YearMonth

use of org.joda.time.YearMonth in project serenity-jbehave by serenity-bdd.

the class WhenConvertingJodaDateTimes method should_detect_MonthYear_format_with_slash.

@Test
public void should_detect_MonthYear_format_with_slash() {
    YearMonthConverter converter = new YearMonthConverter();
    YearMonth convertedTime = (YearMonth) converter.convertValue("1942/10", YearMonth.class);
    assertThat(convertedTime.getMonthOfYear()).isEqualTo(10);
    assertThat(convertedTime.getYear()).isEqualTo(1942);
}
Also used : YearMonth(org.joda.time.YearMonth) Test(org.junit.Test)

Example 5 with YearMonth

use of org.joda.time.YearMonth in project serenity-jbehave by serenity-bdd.

the class WhenConvertingJodaDateTimes method should_detect_MonthYear_format.

@Test
public void should_detect_MonthYear_format() {
    YearMonthConverter converter = new YearMonthConverter();
    YearMonth convertedTime = (YearMonth) converter.convertValue("1942-10", YearMonth.class);
    assertThat(convertedTime.getMonthOfYear()).isEqualTo(10);
    assertThat(convertedTime.getYear()).isEqualTo(1942);
}
Also used : YearMonth(org.joda.time.YearMonth) Test(org.junit.Test)

Aggregations

YearMonth (org.joda.time.YearMonth)7 Test (org.junit.Test)4 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Then (org.jbehave.core.annotations.Then)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 LocalDateTime (org.joda.time.LocalDateTime)1 MonthDay (org.joda.time.MonthDay)1