List of usage examples for java.time.temporal ChronoField DAY_OF_WEEK
ChronoField DAY_OF_WEEK
To view the source code for java.time.temporal ChronoField DAY_OF_WEEK.
Click Source Link
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.getLong(ChronoField.DAY_OF_WEEK)); }
From source file:Main.java
public static void main(String[] args) { DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendLiteral("New Year in ") .appendValue(ChronoField.YEAR).appendLiteral(" is on ") .appendText(ChronoField.DAY_OF_WEEK, TextStyle.FULL_STANDALONE).toFormatter(); LocalDate ld = LocalDate.of(2014, Month.JANUARY, 1); String str = ld.format(formatter); System.out.println(str);/*from ww w .j a va 2 s .c o m*/ }
From source file:Main.java
public static Boolean queryFrom(TemporalAccessor temporal) { if (temporal.isSupported(ChronoField.DAY_OF_MONTH) && temporal.isSupported(ChronoField.DAY_OF_WEEK)) { int dayOfMonth = temporal.get(ChronoField.DAY_OF_MONTH); int weekDay = temporal.get(ChronoField.DAY_OF_WEEK); DayOfWeek dayOfWeek = DayOfWeek.of(weekDay); if (dayOfMonth == 1 && dayOfWeek == DayOfWeek.MONDAY) { return Boolean.TRUE; }/*from ww w .j a v a2s . co m*/ } return Boolean.FALSE; }
From source file:Main.java
/** * This method checks whether the given date object is representing a date at * the weekend (Saturday or Sunday)/* www . ja v a 2s .c o m*/ * * @param date * Date to check, cannot be null * @return TRUE is Saturday or Sunday */ public static boolean isWeekend(LocalDate date) { DayOfWeek dayOfWeek = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK)); switch (dayOfWeek) { case SATURDAY: case SUNDAY: return true; default: return false; } }
From source file:Main.java
/** * The methods calculates the previous working day. It only recognize Saturday * and Sunday as non -working days.//from ww w. j a v a 2s . c om * * @param date * Date as starting point for the calculation, cannot be null * @return The previous working day */ public static LocalDate getPreviousWorkingDay(LocalDate date) { DayOfWeek dayOfWeek = DayOfWeek.of(date.get(ChronoField.DAY_OF_WEEK)); switch (dayOfWeek) { case MONDAY: return date.minus(3, ChronoUnit.DAYS); case SUNDAY: return date.minus(2, ChronoUnit.DAYS); default: return date.minus(1, ChronoUnit.DAYS); } }
From source file:Main.java
@Override public Boolean queryFrom(TemporalAccessor temporal) { if (temporal.isSupported(ChronoField.DAY_OF_MONTH) && temporal.isSupported(ChronoField.DAY_OF_WEEK)) { int dayOfMonth = temporal.get(ChronoField.DAY_OF_MONTH); int weekDay = temporal.get(ChronoField.DAY_OF_WEEK); DayOfWeek dayOfWeek = DayOfWeek.of(weekDay); if (dayOfMonth == 1 && dayOfWeek == DayOfWeek.MONDAY) { return Boolean.TRUE; }//from w w w . ja v a 2 s . c o m } return Boolean.FALSE; }
From source file:FridayThirteenQuery.java
public Boolean queryFrom(TemporalAccessor date) { return ((date.get(ChronoField.DAY_OF_MONTH) == 13) && (date.get(ChronoField.DAY_OF_WEEK) == 5)); }