Search in sources :

Example 66 with Month

use of java.time.Month in project uhgroupings by uhawaii-system-its-ti-iam.

the class DatesTest method month.

@Test
public void month() {
    for (Month month : Month.values()) {
        int year = 2012;
        LocalDate lastOfMonth = Dates.lastDateOfMonth(month, year);
        assertThat(Dates.month(lastOfMonth), is(month));
        LocalDate firstOfMonth = Dates.firstDateOfMonth(month, year);
        assertThat(Dates.month(firstOfMonth), is(month));
    }
}
Also used : Month(java.time.Month) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 67 with Month

use of java.time.Month 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)

Example 68 with Month

use of java.time.Month in project portfolio by buchen.

the class PerformanceHeatmapWidget method addHeaderRow.

private void addHeaderRow() {
    // Top Left is empty
    // $NON-NLS-1$
    new Cell(table, () -> "");
    // no harm in hardcoding the year as each year has the same months
    for (LocalDate m = LocalDate.of(2016, 1, 1); m.getYear() == 2016; m = m.plusMonths(1)) {
        Month month = m.getMonth();
        Cell cell = new Cell(table, () -> {
            int numColumns = getDashboardData().getDashboard().getColumns().size();
            TextStyle textStyle;
            if (numColumns == 1)
                textStyle = TextStyle.FULL;
            else if (numColumns == 2)
                textStyle = TextStyle.SHORT;
            else
                textStyle = TextStyle.NARROW;
            return month.getDisplayName(textStyle, Locale.getDefault());
        });
        GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cell);
    }
}
Also used : Month(java.time.Month) TextStyle(java.time.format.TextStyle) LocalDate(java.time.LocalDate) Point(org.eclipse.swt.graphics.Point)

Aggregations

Month (java.time.Month)68 LocalDate (java.time.LocalDate)40 Test (org.junit.Test)30 Test (org.testng.annotations.Test)20 DayOfWeek (java.time.DayOfWeek)17 LocalDateTime (java.time.LocalDateTime)8 LocalTime (java.time.LocalTime)5 ZoneOffset (java.time.ZoneOffset)5 HashMap (java.util.HashMap)5 DateTimeFormatter (java.time.format.DateTimeFormatter)4 YearMonth (java.time.YearMonth)3 Date (java.util.Date)3 List (java.util.List)3 ArrayList (java.util.ArrayList)2 DateTimeRule (android.icu.util.DateTimeRule)1 UseLocalDateTime (com.baeldung.datetime.UseLocalDateTime)1 EnchantmentEventListener (com.lilithsthrone.controller.eventListeners.EnchantmentEventListener)1 InventorySelectedItemEventListener (com.lilithsthrone.controller.eventListeners.InventorySelectedItemEventListener)1 InventoryTooltipEventListener (com.lilithsthrone.controller.eventListeners.InventoryTooltipEventListener)1 SetContentEventListener (com.lilithsthrone.controller.eventListeners.SetContentEventListener)1