Calendar Vaadin Framework 14+的完整日历4.x不以24小时格式显示

Calendar Vaadin Framework 14+的完整日历4.x不以24小时格式显示,calendar,vaadin,Calendar,Vaadin,我创建了一个完整的日历,它以AM/PM显示时间。在向日历中添加条目时,我将LocalDateTime格式设置为24小时格式,但日历以am/PM格式显示 如何以24小时格式显示日历条目? 我的格式化程序定义为: public static final DateTimeFormatter TWENTY_FOUR_HOURS_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm:ss", AppConstan

我创建了一个完整的日历,它以AM/PM显示时间。在向日历中添加条目时,我将LocalDateTime格式设置为24小时格式,但日历以am/PM格式显示

如何以24小时格式显示日历条目? 我的格式化程序定义为:

public static final DateTimeFormatter TWENTY_FOUR_HOURS_DATE_TIME_FORMATTER = 
    DateTimeFormatter.ofPattern("dd-MMM-yyyy HH:mm:ss", AppConstants.APP_LOCALE);

Entry entry = new Entry();
entry.setEditable(false);
entry.setTitle(game.getHomeClub() + " - " +game.getHomeTeam());

Instant now = Instant.now();

String t = LocalDateTime.of(game.getGameTime().toLocalDate(), game.getGameTime().toLocalTime())
.format(FormattingUtils.TWENTY_FOUR_HOURS_DATE_TIME_FORMATTER);

entry.setStart(calendar.getTimezone().convertToUTC(LocalDateTime.parse(t, FormattingUtils.TWENTY_FOUR_HOURS_DATE_TIME_FORMATTER)));    

entry.setEnd(game.getGameTime().plus(2, ChronoUnit.HOURS));

您需要设置区域设置

@Route(value = "test")
class TestView extends Composite<Div> {

    TestView() {
        Locale defaultLocale = Locale.GERMANY
        FullCalendar calendar = FullCalendarBuilder.create().build()
        calendar.changeView(CalendarViewImpl.TIME_GRID_DAY)
        calendar.setSizeFull()

        RadioButtonGroup<Locale> localeSwitcher = new RadioButtonGroup()

        localeSwitcher.setItems([defaultLocale, Locale.US])
        localeSwitcher.addValueChangeListener({ ev ->
            calendar.setLocale(localeSwitcher.value)
        })
        localeSwitcher.setValue(defaultLocale)
        VerticalLayout layout = new VerticalLayout(localeSwitcher, calendar)
        layout.setSizeFull()

        content.add(layout)
    }
}

上面的Groovy代码为德语区域设置生成以下日历:

这对我们来说是:


欢迎来到SO!我认为您可以通过以下方式提高获得答案的机会:我已将区域设置更改为德国,但时间仍显示在AM/PM中。您能否提供屏幕截图和日历设置的完整代码。->LocalesI已经添加了日历的图像以及我如何初始化日历我看不到你在MyFullCalendar类中做什么。用完整的示例更新了我的答案。MyFullCalendar中没有任何内容,它只是扩展FullCalendar。您的日历实现和我的日历实现有所不同,因为我在Enum CalendarViewImpl.TIME\u GRID\u DAY中没有此值。我使用的日历在这里
@Route(value = "test")
class TestView extends Composite<Div> {

    TestView() {
        Locale defaultLocale = Locale.GERMANY
        FullCalendar calendar = FullCalendarBuilder.create().build()
        calendar.changeView(CalendarViewImpl.TIME_GRID_DAY)
        calendar.setSizeFull()

        RadioButtonGroup<Locale> localeSwitcher = new RadioButtonGroup()

        localeSwitcher.setItems([defaultLocale, Locale.US])
        localeSwitcher.addValueChangeListener({ ev ->
            calendar.setLocale(localeSwitcher.value)
        })
        localeSwitcher.setValue(defaultLocale)
        VerticalLayout layout = new VerticalLayout(localeSwitcher, calendar)
        layout.setSizeFull()

        content.add(layout)
    }
}