Java Code Examples for java.time.ZonedDateTime#getMinute()
The following examples show how to use
java.time.ZonedDateTime#getMinute() .
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: EmailService.java From sherlock with GNU General Public License v3.0 | 6 votes |
/** * Sends the consolidated alerts over the specified trigger period. * @param zonedDateTime current date as ZonedDateTime object * @param trigger trigger name value */ public void sendConsolidatedEmail(ZonedDateTime zonedDateTime, String trigger) throws IOException { List<EmailMetaData> emails = emailMetadataAccessor.getAllEmailMetadataByTrigger(trigger); log.info("Found {} emails for {} trigger index", emails.size(), trigger); for (EmailMetaData emailMetaData : emails) { int hour = Integer.valueOf(emailMetaData.getSendOutHour()); int minute = Integer.valueOf(emailMetaData.getSendOutMinute()); boolean isTimeToSend = trigger.equalsIgnoreCase(Triggers.HOUR.toString()) ? zonedDateTime.getMinute() == minute : zonedDateTime.getHour() == hour && zonedDateTime.getMinute() == minute; if (isTimeToSend) { List<AnomalyReport> anomalyReports = anomalyReportAccessor.getAnomalyReportsForEmailId(emailMetaData.getEmailId()); List<AnomalyReport> filteredReports = anomalyReports.stream() .filter(a -> !a.getStatus().equalsIgnoreCase(Constants.SUCCESS)) .collect(Collectors.toList()); log.info("Sending {} anomaly reports to {}", filteredReports.size(), emailMetaData.getEmailId()); if (filteredReports.size() > 0) { if (!sendEmail(Constants.SHERLOCK, Arrays.asList(emailMetaData.getEmailId()), filteredReports)) { log.error("Error while sending email: {}, trigger: {}!", emailMetaData.getEmailId(), trigger); } } } } }
Example 2
Source File: TermExpression.java From jstarcraft-core with Apache License 2.0 | 6 votes |
@Override public boolean isMatchDateTime(ZonedDateTime dateTime) { int year = dateTime.getYear(); int month = dateTime.getMonthValue(); int day = dateTime.getDayOfMonth(); int term; int hour = dateTime.getHour(); int minute = dateTime.getMinute(); int second = dateTime.getSecond(); if (seconds.get(second) && minutes.get(minute) && hours.get(hour)) { term = (month - 1) * 2; if (TermType.values()[term].getDate(year).getDayOfMonth() == day) { return true; } term++; if (TermType.values()[term].getDate(year).getDayOfMonth() == day) { return true; } } return false; }
Example 3
Source File: RoundLcdClockSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawMinutes(final ZonedDateTime TIME) { int minCounter = 1; double strokeWidth = size * 0.06; minutesCtx.clearRect(0, 0, size, size); minutesCtx.setLineCap(StrokeLineCap.BUTT); for (int i = 450 ; i >= 90 ; i--) { minutesCtx.save(); if (i % 6 == 0) { // draw minutes if (minCounter <= TIME.getMinute()) { minutesCtx.setStroke(minCounter % 5 == 0 ? fiveMinuteColor : minuteColor); minutesCtx.setLineWidth(strokeWidth); minutesCtx.strokeArc(strokeWidth * 0.5 + strokeWidth * 1.1, strokeWidth * 0.5 + strokeWidth * 1.1, size - strokeWidth - strokeWidth * 2.2, size - strokeWidth - strokeWidth * 2.2, i + 1 - 6, 4, ArcType.OPEN); minCounter++; } } minutesCtx.restore(); } }
Example 4
Source File: SingleExecutionTime.java From cron-utils with Apache License 2.0 | 6 votes |
private boolean dateValuesInExpectedRanges(final ZonedDateTime validCronDate, final ZonedDateTime date) { boolean everythingInRange = true; if (cronDefinition.getFieldDefinition(YEAR) != null) { everythingInRange = validCronDate.getYear() == date.getYear(); } if (cronDefinition.getFieldDefinition(MONTH) != null) { everythingInRange = everythingInRange && validCronDate.getMonthValue() == date.getMonthValue(); } if (cronDefinition.getFieldDefinition(DAY_OF_MONTH) != null) { everythingInRange = everythingInRange && validCronDate.getDayOfMonth() == date.getDayOfMonth(); } if (cronDefinition.getFieldDefinition(DAY_OF_WEEK) != null) { everythingInRange = everythingInRange && validCronDate.getDayOfWeek().getValue() == date.getDayOfWeek().getValue(); } if (cronDefinition.getFieldDefinition(HOUR) != null) { everythingInRange = everythingInRange && validCronDate.getHour() == date.getHour(); } if (cronDefinition.getFieldDefinition(MINUTE) != null) { everythingInRange = everythingInRange && validCronDate.getMinute() == date.getMinute(); } if (cronDefinition.getFieldDefinition(SECOND) != null) { everythingInRange = everythingInRange && validCronDate.getSecond() == date.getSecond(); } return everythingInRange; }
Example 5
Source File: JavatimeTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 6
Source File: JavatimeTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 7
Source File: Clock.java From Medusa with Apache License 2.0 | 5 votes |
/** * Calling this method will check for the current time of the day and * switches on/off the night mode. * @param TIME */ private void checkForNight(final ZonedDateTime TIME) { int hour = TIME.getHour(); int minute = TIME.getMinute(); if (0 <= hour && minute >= 0 && hour <= 5 && minute <= 59|| 17 <= hour && minute <= 59 && hour <= 23 && minute <= 59) { if(isNightMode()) return; setNightMode(true); } else { if (!isNightMode()) return; setNightMode(false); } }
Example 8
Source File: BackupTask.java From sherlock with GNU General Public License v3.0 | 5 votes |
/** * Method to backup redis data as redis local dump and (as json dump if specified). * @param timestampMinutes ping timestamp (in minutes) of backup task thread * @throws IOException exception */ public void backupRedisDB(long timestampMinutes) throws IOException { ZonedDateTime date = TimeUtils.zonedDateTimeFromMinutes(timestampMinutes); // save redis snapshot if (date.getMinute() == 0 && date.getHour() == 0) { jobMetadataAccessor.saveRedisJobsMetadata(); // save redis data as json file if path is specified if (CLISettings.BACKUP_REDIS_DB_PATH != null) { BackupUtils.startBackup(); } } }
Example 9
Source File: JavatimeTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 10
Source File: JavatimeTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 11
Source File: JavatimeTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 12
Source File: TimeHelper.java From teammates with GNU General Public License v2.0 | 5 votes |
/** * Formats a datetime stamp from an {@code instant} using a formatting pattern. * * <p>Note: a formatting pattern containing 'a' (for the period; AM/PM) is treated differently at noon/midday. * Using that pattern with a datetime whose time falls on "12:00 PM" will cause it to be formatted as "12:00 NOON".</p> * * @param instant the instant to be formatted * @param timeZone the time zone to compute local datetime * @param pattern formatting pattern, see Oracle docs for DateTimeFormatter for pattern table * @return the formatted datetime stamp string */ private static String formatInstant(Instant instant, ZoneId timeZone, String pattern) { if (instant == null || timeZone == null || pattern == null) { return ""; } ZonedDateTime zonedDateTime = instant.atZone(timeZone); String processedPattern = pattern; if (zonedDateTime.getHour() == 12 && zonedDateTime.getMinute() == 0) { processedPattern = pattern.replace("a", "'NOON'"); } DateTimeFormatter formatter = DateTimeFormatter.ofPattern(processedPattern); return zonedDateTime.format(formatter); }
Example 13
Source File: JavatimeTest.java From hottub with GNU General Public License v2.0 | 5 votes |
private static boolean isEqual(LocalDateTime ldt, Timestamp ts) { ZonedDateTime zdt = ZonedDateTime.of(ldt, ZoneId.systemDefault()); return zdt.getYear() == ts.getYear() + 1900 && zdt.getMonthValue() == ts.getMonth() + 1 && zdt.getDayOfMonth() == ts.getDate() && zdt.getHour() == ts.getHours() && zdt.getMinute() == ts.getMinutes() && zdt.getSecond() == ts.getSeconds() && zdt.getNano() == ts.getNanos(); }
Example 14
Source File: PearClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override public void updateTime(final ZonedDateTime TIME) { if (clock.isDiscreteMinutes()) { minuteRotate.setAngle(TIME.getMinute() * 6); } else { minuteRotate.setAngle(TIME.getMinute() * 6 + TIME.getSecond() * 0.1); } if (second.isVisible()) { if (clock.isDiscreteSeconds()) { secondRotate.setAngle(TIME.getSecond() * 6); } else { secondRotate.setAngle(TIME.getSecond() * 6 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006); } } if (clock.isDiscreteHours()) { hourRotate.setAngle(TIME.getHour() * 30); } else { hourRotate.setAngle(0.5 * (60 * TIME.getHour() + TIME.getMinute())); } if (text.isVisible()) { text.setText(TIME_FORMATTER.format(TIME)); Helper.adjustTextSize(text, 0.6 * size, size * 0.12); text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.6); } if (dateText.isVisible()) { dateText.setText(dateTextFormatter.format(TIME).toUpperCase()); Helper.adjustTextSize(dateText, 0.3 * size, size * 0.05); dateText.relocate(((size * 0.5) - dateText.getLayoutBounds().getWidth()) * 0.5 + (size * 0.4), (size - dateText.getLayoutBounds().getHeight()) * 0.5); } if (dateNumber.isVisible()) { dateNumber.setText(DATE_NUMBER_FORMATTER.format(TIME).toUpperCase()); Helper.adjustTextSize(dateNumber, 0.3 * size, size * 0.05); dateNumber.relocate(((size * 0.5) - dateNumber.getLayoutBounds().getWidth()) * 0.5 + (size * 0.51), (size - dateNumber.getLayoutBounds().getHeight()) * 0.5); } // Show all alarms within the next hour if (TIME.getMinute() == 0 && TIME.getSecond() == 0) Helper.drawAlarms(clock, size, 0.0225, 0.4775, alarmMap, dateTimeFormatter, TIME);; // Highlight Areas and Sections if (highlightAreas | highlightSections) { sectionsAndAreasCtx.clearRect(0, 0, size, size); if (areasVisible) Helper.drawTimeAreas(clock, sectionsAndAreasCtx, areas, size, 0, 0, 1, 1); if (sectionsVisible) Helper.drawTimeSections(clock, sectionsAndAreasCtx, sections, size, 0.02, 0.02, 0.96, 0.96, 0.04); } }
Example 15
Source File: Scatter3dArranger.java From constellation with Apache License 2.0 | 4 votes |
private float getFloatValueFromObject(Object attributeValue, boolean logarithmic) { if (attributeValue == null) { return 0.0f; } if (attributeValue instanceof Float) { return scaleValue((float) attributeValue, logarithmic); } if (attributeValue instanceof Double) { return scaleValue((float) attributeValue, logarithmic); } if (attributeValue instanceof String) { String val = (String) attributeValue; float finalVal = 0.0f; float multiplier = 1; for (int i = 0; i < val.length(); i++) { char ch = val.charAt(i); float chVal = (float) ch; finalVal += ((float) chVal) * multiplier; multiplier /= 26; } return scaleValue(finalVal, logarithmic); } if (attributeValue instanceof Integer) { float ret = (Integer) attributeValue; return scaleValue(ret, logarithmic); } if (attributeValue instanceof ConstellationColor) { ConstellationColor color = (ConstellationColor) attributeValue; float red = color.getRed() / 256; float green = color.getGreen() / 256; float blue = color.getBlue() / 256; return scaleValue((red + green + blue) * 100, logarithmic); } if (attributeValue instanceof ZonedDateTime) { ZonedDateTime c = (ZonedDateTime) attributeValue; float year = c.getYear(); float month = c.getMonthValue(); float monthDay = c.getDayOfMonth(); float hour = c.getHour(); float minute = c.getMinute(); return scaleValue((year - 2010) + month / 12 + monthDay / (366) + hour / (366 * 24) + minute / (366 * 24 * 60), logarithmic); } if (attributeValue instanceof RawData) { String s = ((RawData) attributeValue).toString(); return getFloatValueFromObject(s, logarithmic); } return 0.0f; }
Example 16
Source File: PlainClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override public void updateTime(final ZonedDateTime TIME) { if (clock.isDiscreteMinutes()) { minuteRotate.setAngle(TIME.getMinute() * 6); } else { minuteRotate.setAngle(TIME.getMinute() * 6 + TIME.getSecond() * 0.1); } if (second.isVisible()) { if (clock.isDiscreteSeconds()) { secondRotate.setAngle(TIME.getSecond() * 6); } else { secondRotate.setAngle(TIME.getSecond() * 6 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006); } } if (clock.isDiscreteHours()) { hourRotate.setAngle(TIME.getHour() * 30); } else { hourRotate.setAngle(0.5 * (60 * TIME.getHour() + TIME.getMinute())); } if (text.isVisible()) { text.setText(TIME_FORMATTER.format(TIME)); Helper.adjustTextSize(text, 0.6 * size, size * 0.12); text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.6); } if (dateNumber.isVisible()) { dateNumber.setText(DATE_NUMBER_FORMATER.format(TIME).toUpperCase()); Helper.adjustTextSize(dateNumber, 0.3 * size, size * 0.05); dateNumber.relocate(((size * 0.5) - dateNumber.getLayoutBounds().getWidth()) * 0.5 + (size * 0.6), (size - dateNumber.getLayoutBounds().getHeight()) * 0.5); } // Show all alarms within the next hour if (TIME.getMinute() == 0 && TIME.getSecond() == 0) Helper.drawAlarms(clock, size, 0.015, 0.46, alarmMap, DATE_TIME_FORMATTER, TIME); // Highlight Areas and Sections if (highlightAreas | highlightSections) { sectionsAndAreasCtx.clearRect(0, 0, size, size); if (areasVisible) Helper.drawTimeAreas(clock, sectionsAndAreasCtx, areas, size, 0.025, 0.025, 0.95, 0.95); if (sectionsVisible) Helper.drawTimeSections(clock, sectionsAndAreasCtx, sections, size, 0.06, 0.06, 0.88, 0.88, 0.07); } }
Example 17
Source File: Calendar.java From calendar-component with Apache License 2.0 | 4 votes |
private static int getMinuteOfDay(ZonedDateTime date) { return date.getHour() * 60 + date.getMinute(); }
Example 18
Source File: CronExpression.java From cron with Apache License 2.0 | 4 votes |
@Override int getValue(ZonedDateTime dateTime) { return dateTime.getMinute(); }
Example 19
Source File: ClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override public void updateTime(final ZonedDateTime TIME) { if (getSkinnable().isDiscreteHours()) { hourRotate.setAngle(TIME.getHour() * 30); } else { hourRotate.setAngle(0.5 * (60 * TIME.getHour() + TIME.getMinute())); } if (getSkinnable().isDiscreteMinutes()) { minuteRotate.setAngle(TIME.getMinute() * 6); } else { minuteRotate.setAngle(TIME.getMinute() * 6 + TIME.getSecond() * 0.1); } if (second.isVisible()) { if (getSkinnable().isDiscreteSeconds()) { secondRotate.setAngle(TIME.getSecond() * 6); } else { secondRotate.setAngle(TIME.getSecond() * 6 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006); } } if (text.isVisible()) { text.setText(TIME_FORMATTER.format(TIME)); Helper.adjustTextSize(text, 0.6 * size, size * 0.12); text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.6); } if (dateText.isVisible()) { dateText.setText(dateFormatter.format(TIME).toUpperCase()); Helper.adjustTextSize(dateText, 0.3 * size, size * 0.05); dateText.relocate(((size * 0.5) - dateText.getLayoutBounds().getWidth()) * 0.5 + (size * 0.45), (size - dateText.getLayoutBounds().getHeight()) * 0.5); } // Show all alarms within the next hour if (TIME.getMinute() == 0 && TIME.getSecond() == 0) Helper.drawAlarms(getSkinnable(), size, 0.02, 0.45, alarmMap, dateTimeFormatter, TIME); // Highlight Areas and Sections if (highlightAreas | highlightSections) { sectionsAndAreasCtx.clearRect(0, 0, size, size); if (areasVisible) Helper.drawTimeAreas(getSkinnable(), sectionsAndAreasCtx, areas, size, 0.03, 0.03, 0.94, 0.94); if (sectionsVisible) Helper.drawTimeSections(getSkinnable(), sectionsAndAreasCtx, sections, size, 0.065, 0.065, 0.87, 0.87, 0.07); } }
Example 20
Source File: IndustrialClockSkin.java From Medusa with Apache License 2.0 | 4 votes |
@Override public void updateTime(final ZonedDateTime TIME) { if (clock.isDiscreteMinutes()) { minuteRotate.setAngle(TIME.getMinute() * 6); } else { minuteRotate.setAngle(TIME.getMinute() * 6 + TIME.getSecond() * 0.1); } if (second.isVisible()) { if (clock.isDiscreteSeconds()) { secondRotate.setAngle(TIME.getSecond() * 6); } else { secondRotate.setAngle(TIME.getSecond() * 6 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006); } } if (clock.isDiscreteHours()) { hourRotate.setAngle(TIME.getHour() * 30); } else { hourRotate.setAngle(0.5 * (60 * TIME.getHour() + TIME.getMinute())); } if (text.isVisible()) { text.setText(TIME_FORMATTER.format(TIME)); Helper.adjustTextSize(text, 0.6 * size, size * 0.12); text.relocate((size - text.getLayoutBounds().getWidth()) * 0.5, size * 0.6); } if (dateText.isVisible()) { dateText.setText(dateTextFormatter.format(TIME).toUpperCase()); Helper.adjustTextSize(dateText, 0.3 * size, size * 0.05); dateText.relocate(((size * 0.5) - dateText.getLayoutBounds().getWidth()) * 0.5 + (size * 0.4), (size - dateText.getLayoutBounds().getHeight()) * 0.5); } if (dateNumber.isVisible()) { dateNumber.setText(DATE_NUMBER_FORMATTER.format(TIME).toUpperCase()); Helper.adjustTextSize(dateNumber, 0.3 * size, size * 0.05); dateNumber.relocate(((size * 0.5) - dateNumber.getLayoutBounds().getWidth()) * 0.5 + (size * 0.51), (size - dateNumber.getLayoutBounds().getHeight()) * 0.5); } // Show all alarms within the next hour if (TIME.getMinute() == 0 && TIME.getSecond() == 0) Helper.drawAlarms(clock, size, 0.0225, 0.4775, alarmMap, dateTimeFormatter, TIME);; // Highlight Areas and Sections if (highlightAreas | highlightSections) { sectionsAndAreasCtx.clearRect(0, 0, size, size); if (areasVisible) Helper.drawTimeAreas(clock, sectionsAndAreasCtx, areas, size, 0, 0, 1, 1); if (sectionsVisible) Helper.drawTimeSections(clock, sectionsAndAreasCtx, sections, size, 0.02, 0.02, 0.96, 0.96, 0.04); } }