Search in sources :

Example 1 with TextStyle

use of java.time.format.TextStyle in project jphp by jphp-compiler.

the class DateTimeParserTest method justMonth.

@Test
public void justMonth() {
    Locale l = Locale.US;
    for (Month month : Month.values()) {
        for (TextStyle value : Arrays.asList(TextStyle.FULL, TextStyle.SHORT)) {
            String monthName = month.getDisplayName(value, l);
            ZonedDateTime now = now();
            ZonedDateTime expected = now.withMonth(month.getValue()).truncatedTo(DAYS);
            assertThat(parse(monthName, now)).isEqualToIgnoringSeconds(expected);
            assertThat(parse(monthName.toLowerCase(), now)).isEqualToIgnoringSeconds(expected);
            assertThat(parse(monthName.toUpperCase(), now)).isEqualToIgnoringSeconds(expected);
        }
    }
}
Also used : Locale(java.util.Locale) Month(java.time.Month) TextStyle(java.time.format.TextStyle) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 2 with TextStyle

use of java.time.format.TextStyle 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)2 TextStyle (java.time.format.TextStyle)2 LocalDate (java.time.LocalDate)1 ZonedDateTime (java.time.ZonedDateTime)1 Locale (java.util.Locale)1 Point (org.eclipse.swt.graphics.Point)1 Test (org.junit.Test)1