List of usage examples for java.time.format DateTimeFormatter ofLocalizedTime
public static DateTimeFormatter ofLocalizedTime(FormatStyle timeStyle)
From source file:Main.java
public static void main(String... args) { DateTimeFormatter germanFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT) .withLocale(Locale.GERMAN); LocalTime leetTime = LocalTime.parse("13:37", germanFormatter); System.out.println(leetTime); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld = LocalDate.of(2014, Month.JUNE, 21); LocalTime lt = LocalTime.of(17, 30, 20); LocalDateTime ldt = LocalDateTime.of(ld, lt); DateTimeFormatter fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT); System.out.println("Formatter Default Locale: " + fmt.getLocale()); System.out.println("Short Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM); System.out.println("Medium Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG); System.out.println("Long Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL); System.out.println("Full Date: " + fmt.format(ld)); fmt = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT); System.out.println("Short Time: " + fmt.format(lt)); fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT); System.out.println("Short Datetime: " + fmt.format(ldt)); fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); System.out.println("Medium Datetime: " + fmt.format(ldt)); // Use German locale to format the datetime in medius style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(Locale.GERMAN); System.out.println(fmt.format(ldt)); // Use Indian(English) locale to format datetime in short style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(new Locale("en", "IN")); System.out.println(fmt.format(ldt)); // Use Indian(English) locale to format datetime in medium style fmt = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(new Locale("en", "IN")); System.out.println(fmt.format(ldt)); }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component getTimeRow(User user, LocalTime time) { HorizontalLayout layoutTimeRow = new HorizontalLayout(); layoutTimeRow.setWidth("100%"); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT); Label labelTime = new Label(time.format(formatter)); Button buttonDelete = new Button(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.setWidth("80px"); buttonDelete.addClickListener(e -> { if (layoutClippingTimes.getComponentCount() > 1) { layoutClippingTimes.removeComponent(layoutTimeRow); UserUtils.removeClippingSendTime(user, time); } else {//from ww w . ja va2s . c o m VaadinUtils.errorNotification(Language.get(Word.AT_LREAST_ONE_TIME)); } }); layoutTimeRow.addComponents(labelTime, buttonDelete); layoutTimeRow.setComponentAlignment(labelTime, Alignment.MIDDLE_LEFT); layoutTimeRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); layoutTimeRow.setExpandRatio(labelTime, 5); return layoutTimeRow; }