Java Code Examples for java.time.ZonedDateTime#getDayOfWeek()
The following examples show how to use
java.time.ZonedDateTime#getDayOfWeek() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Calendar.java From calendar-component with Apache License 2.0 | 6 votes |
/** * Gets a date that is last day in the week that target given date belongs * to. * * @param date * Target date * @return Date that is last date in same week that given date is. */ protected ZonedDateTime getLastDayOfWeek(ZonedDateTime date) { DayOfWeek firstDayOfWeek = getFirstDayOfWeek(); date = date.plus(1, ChronoUnit.DAYS); // Roll to weeks last day using firstdayofweek. Roll until FDofW is // found and then roll back one day. while (firstDayOfWeek != date.getDayOfWeek()) { date = date.plus(1, ChronoUnit.DAYS); } date = date.minus(1, ChronoUnit.DAYS); return date; }
Example 2
Source File: Calendar.java From calendar-component with Apache License 2.0 | 5 votes |
/** * Gets a date that is first day in the week that target given date belongs * to. * * @param date * Target date * @return Date that is first date in same week that given date is. */ protected ZonedDateTime getFirstDayOfWeek(ZonedDateTime date) { DayOfWeek firstDayOfWeek = getFirstDayOfWeek(); while (firstDayOfWeek != date.getDayOfWeek()) { date = date.minus(1, ChronoUnit.DAYS); } return date; }
Example 3
Source File: EphemerisManagerImpl.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isInDayset(String daysetName, ZonedDateTime date) { if (daysets.containsKey(daysetName)) { DayOfWeek dow = date.getDayOfWeek(); return daysets.get(daysetName).contains(dow); } else { logger.warn("This dayset is not configured : {}", daysetName); return false; } }
Example 4
Source File: TimerControlTileSkin.java From OEE-Designer with MIT License | 4 votes |
private void drawTimeSections() { if (sectionMap.isEmpty()) return; ZonedDateTime time = tile.getTime(); DayOfWeek day = time.getDayOfWeek(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double offset = 90; double angleStep = 360.0 / 60.0; boolean highlightSections = tile.isHighlightSections(); for (TimeSection section : sectionMap.keySet()) { LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) : (!isStartAM || !isStopAM); if (!section.getDays().contains(day)) { draw = false; } if (!section.isActive()) { draw = false; } if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } Arc arc = sectionMap.get(section); arc.setCenterX(clockSize * 0.5); arc.setCenterY(clockSize * 0.5); arc.setRadiusX(clockSize * 0.45); arc.setRadiusY(clockSize * 0.45); arc.setStartAngle(-(offset + sectionStartAngle)); arc.setLength(-sectionAngleExtend); arc.setType(ArcType.OPEN); arc.setStrokeWidth(clockSize * 0.04); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(null); if (highlightSections) { arc.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { arc.setStroke(section.getColor()); } } } }
Example 5
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
private void drawTimeSections() { if (sectionMap.isEmpty()) return; ZonedDateTime time = tile.getTime(); DayOfWeek day = time.getDayOfWeek(); boolean isAM = time.get(ChronoField.AMPM_OF_DAY) == 0; double offset = 90; double angleStep = 360.0 / 60.0; boolean highlightSections = tile.isHighlightSections(); for (TimeSection section : sectionMap.keySet()) { LocalTime start = section.getStart(); LocalTime stop = section.getStop(); boolean isStartAM = start.get(ChronoField.AMPM_OF_DAY) == 0; boolean isStopAM = stop.get(ChronoField.AMPM_OF_DAY) == 0; boolean draw = isAM ? (isStartAM || isStopAM) : (!isStartAM || !isStopAM); if (!section.getDays().contains(day)) { draw = false; } if (!section.isActive()) { draw = false; } if (draw) { double sectionStartAngle = (start.getHour() % 12 * 5.0 + start.getMinute() / 12.0 + start.getSecond() / 300.0) * angleStep + 180; double sectionAngleExtend = ((stop.getHour() - start.getHour()) % 12 * 5.0 + (stop.getMinute() - start.getMinute()) / 12.0 + (stop.getSecond() - start.getSecond()) / 300.0) * angleStep; if (start.getHour() > stop.getHour()) { sectionAngleExtend = (360.0 - Math.abs(sectionAngleExtend)); } Arc arc = sectionMap.get(section); arc.setCenterX(clockSize * 0.5); arc.setCenterY(clockSize * 0.5); arc.setRadiusX(clockSize * 0.45); arc.setRadiusY(clockSize * 0.45); arc.setStartAngle(-(offset + sectionStartAngle)); arc.setLength(-sectionAngleExtend); arc.setType(ArcType.OPEN); arc.setStrokeWidth(clockSize * 0.04); arc.setStrokeLineCap(StrokeLineCap.BUTT); arc.setFill(null); if (highlightSections) { arc.setStroke(section.contains(time.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { arc.setStroke(section.getColor()); } } } }