List of usage examples for java.time DayOfWeek getDisplayName
public String getDisplayName(TextStyle style, Locale locale)
From source file:Main.java
public static void main(String[] args) { LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21); DayOfWeek dayOfWeek = DayOfWeek.from(localDate); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, Locale.CANADA)); System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, Locale.CANADA)); }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 15); // 2014-02-15 DayOfWeek dayOfWeek = date.getDayOfWeek(); // SATURDAY dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:Main.java
public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15 // ISO-8601 standard // the day-of-week to represent, from 1 (Monday) to 7 (Sunday) DayOfWeek dayOfWeek = date.getDayOfWeek(); System.out.println(dayOfWeek); // SATURDAY System.out.println(DayOfWeek.of(3)); // WEDNESDAY System.out.println(dayOfWeek.getValue()); // 6 System.out.println(dayOfWeek.name()); // SATURDAY System.out.println(date.getDayOfMonth()); // 15 System.out.println(date.atStartOfDay()); // 2014-02-15 00:00 System.out.println("DayOfWeek"); dayOfWeek = DayOfWeek.FRIDAY; Locale locale = Locale.getDefault(); System.out.println(dayOfWeek.getDisplayName(TextStyle.FULL, locale)); // Friday System.out.println(dayOfWeek.getDisplayName(TextStyle.NARROW, locale)); // F System.out.println(dayOfWeek.getDisplayName(TextStyle.SHORT, locale)); // Fri }
From source file:org.geoserver.taskmanager.web.panel.BatchesPanel.java
private String formatFrequency(String frequency) { if (frequency == null) { return null; }//from ww w.j av a 2 s . co m Matcher matcher = FrequencyUtil.DAILY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); if (minutes <= 60 && hour < 24) { return new ParamResourceModel("Daily", this).getString() + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } else { matcher = FrequencyUtil.WEEKLY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); DayOfWeek day = FrequencyUtil.findDayOfWeek(matcher.group(3)); if (minutes <= 60 && hour < 24 && day != null) { return new ParamResourceModel("Weekly", this).getString() + ", " + day.getDisplayName(TextStyle.FULL, getLocale()) + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } else { matcher = FrequencyUtil.MONTHLY_PATTERN.matcher(frequency); if (matcher.matches()) { int minutes = Integer.parseInt(matcher.group(1)); int hour = Integer.parseInt(matcher.group(2)); int day = Integer.parseInt(matcher.group(3)); if (minutes <= 60 && hour < 24 && day > 0 && day <= 28) { return new ParamResourceModel("Monthly", this).getString() + ", " + new ParamResourceModel("Day", this).getString() + " " + day + ", " + String.format("%02d", hour) + ":" + String.format("%02d", minutes); } } } } return new ParamResourceModel("Custom", this).getString() + ", " + frequency; }