Java Code Examples for java.time.ZonedDateTime#getSecond()
The following examples show how to use
java.time.ZonedDateTime#getSecond() .
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: RoundLcdClockSkin.java From Medusa with Apache License 2.0 | 6 votes |
private void drawSeconds(final ZonedDateTime TIME) { int secCounter = 1; double strokeWidth = size * 0.06; secondsCtx.setLineCap(StrokeLineCap.BUTT); secondsCtx.clearRect(0, 0, size, size); for (int i = 450 ; i >= 90 ; i--) { secondsCtx.save(); if (i % 6 == 0) { // draw seconds if (secCounter <= TIME.getSecond() + 1) { secondsCtx.setStroke(secondColor); secondsCtx.setLineWidth(strokeWidth * 0.25); secondsCtx.strokeArc(strokeWidth * 0.5 + strokeWidth * 1.8, strokeWidth * 0.5 + strokeWidth * 1.8, size - strokeWidth - strokeWidth * 3.6, size - strokeWidth - strokeWidth * 3.6, i + 1 - 6, 4, ArcType.OPEN); secCounter++; } } secondsCtx.restore(); } }
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: SerializerH3ZonedDateTime.java From baratine with GNU General Public License v2.0 | 6 votes |
@Override public void writeObject(OutRawH3 os, int defId, ZonedDateTime time, OutH3 out) { os.writeObject(typeSequence()); long l = time.getYear() << 8; l |= time.getMonthValue(); l <<= 8; l |= time.getDayOfMonth(); l <<= 32; l |= (time.getHour() * 60 * 60 + time.getMinute() * 60 + time.getSecond()); os.writeLong(l); os.writeLong(time.getNano()); os.writeString(time.getZone().getId()); }
Example 4
Source File: ScheduledTaskTest.java From blackduck-alert with Apache License 2.0 | 6 votes |
@Test public void testNextFormattedRuntime() { final Long millisecondsToNextRun = 10000L; ZonedDateTime currentUTCTime = ZonedDateTime.now(ZoneOffset.UTC); ZonedDateTime expectedDateTime = currentUTCTime.plus(millisecondsToNextRun, ChronoUnit.MILLIS); int seconds = expectedDateTime.getSecond(); if (seconds >= 30) { expectedDateTime = expectedDateTime.truncatedTo(ChronoUnit.MINUTES).plusMinutes(1); } else { expectedDateTime = expectedDateTime.truncatedTo(ChronoUnit.MINUTES); } String expectedNextRunTime = expectedDateTime.format(DateTimeFormatter.ofPattern(ScheduledTask.FORMAT_PATTERN)) + " UTC"; Mockito.doReturn(future).when(taskScheduler).schedule(Mockito.any(), Mockito.any(CronTrigger.class)); Mockito.when(future.getDelay(TimeUnit.MILLISECONDS)).thenReturn(millisecondsToNextRun); task.scheduleExecution(validCronExpression); Optional<String> nextRunTime = task.getFormatedNextRunTime(); assertTrue(nextRunTime.isPresent()); String nextTime = nextRunTime.get(); assertEquals(expectedNextRunTime, nextTime); }
Example 5
Source File: ScheduledTask.java From blackduck-alert with Apache License 2.0 | 6 votes |
public Optional<String> getFormatedNextRunTime() { Optional<Long> msToNextRun = getMillisecondsToNextRun(); if (msToNextRun.isPresent()) { ZonedDateTime currentUTCTime = ZonedDateTime.now(ZoneOffset.UTC); ZonedDateTime nextRunTime = currentUTCTime.plus(msToNextRun.get(), ChronoUnit.MILLIS); int seconds = nextRunTime.getSecond(); if (seconds >= 30) { nextRunTime = nextRunTime.truncatedTo(ChronoUnit.MINUTES).plusMinutes(1); } else { nextRunTime = nextRunTime.truncatedTo(ChronoUnit.MINUTES); } String formattedString = nextRunTime.format(DateTimeFormatter.ofPattern(FORMAT_PATTERN)); return Optional.of(formattedString + " UTC"); } return Optional.empty(); }
Example 6
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 7
Source File: DBClockSkin.java From Medusa with Apache License 2.0 | 5 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 (clock.isDiscreteSeconds() && second.isVisible()) { 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); } // Show all alarms within the next hour if (TIME.getMinute() == 0 && TIME.getSecond() == 0) Helper.drawAlarms(clock, size, 0.02, 0.445, 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.035, 0.035, 0.93, 0.93); if (sectionsVisible) Helper.drawTimeSections(clock, sectionsAndAreasCtx, sections, size, 0.056, 0.056, 0.89, 0.89, 0.0395); } }
Example 8
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 9
Source File: JavatimeTest.java From openjdk-8-source 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 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 11
Source File: TimelineTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private int getNoOfVerticalLines(final Instant START, final Duration TIME_PERIOD) { long maxTime = START.getEpochSecond(); long minTime = START.minus(TIME_PERIOD.toSeconds(), ChronoUnit.SECONDS).getEpochSecond(); int lineCountX = 0; ZonedDateTime dateTime; for (long t = minTime ; t < maxTime ; t++) { dateTime = ZonedDateTime.ofInstant(Instant.ofEpochSecond(t), tile.getZoneId()); if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_MONTH) { if (1 == dateTime.getDayOfMonth() && 0 == dateTime.getHour() && 0 == dateTime.getMinute() && 0 == dateTime.getSecond()) { // Full day lineCountX++; } } else if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_DAY) { if (0 == dateTime.getHour() && 0 == dateTime.getMinute() && 0 == dateTime.getSecond()) { // Full day lineCountX++; } } else if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_DAY / 2) { if (dateTime.getHour() % 2 == 0 && 0 == dateTime.getMinute() && 0 == dateTime.getSecond()) { // Full hour lineCountX++; } } else if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_DAY / 4) { if (0 == dateTime.getMinute() && 0 == dateTime.getSecond()) { // Full hour lineCountX++; } } else if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_HOUR) { if ((0 == dateTime.getMinute() || 30 == dateTime.getMinute()) && 0 == dateTime.getSecond()) { // Full hour and half hour lineCountX++; } } else if (TIME_PERIOD.getSeconds() > Helper.SECONDS_PER_MINUTE) { if (0 == dateTime.getSecond() && dateTime.getMinute() % 5 == 0) { // 5 minutes lineCountX++; } } else { if (dateTime.getSecond() % 10 == 0) { // 10 seconds lineCountX++; } } } return lineCountX; }
Example 12
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 13
Source File: DesignClockSkin.java From Medusa with Apache License 2.0 | 5 votes |
@Override public void updateTime(final ZonedDateTime TIME) { double rotationAngle = 0.5 * (60 * TIME.getHour() + TIME.getMinute() + TIME.getSecond() * 0.0166666667 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.0000166667); double rotationX = size * 0.5 + rotationRadius * Math.sin(Math.toRadians(rotationAngle + 180)); double rotationY = size * 0.5 - rotationRadius * Math.cos(Math.toRadians(rotationAngle + 180)); tickCanvas.relocate(rotationX - tickCanvas.getHeight() * 0.5, rotationY - tickCanvas.getHeight() * 0.5); needle.setRotate(rotationAngle); double canvasCenterX = tickCanvas.getWidth() * 0.5; double canvasCenterY = tickCanvas.getHeight() * 0.5; double radius = tickCanvas.getHeight() * 0.372; double rotX = canvasCenterX + radius * Math.sin(Math.toRadians(rotationAngle)); double rotY = canvasCenterY - radius * Math.cos(Math.toRadians(rotationAngle)); clip.setCenterX(rotX); clip.setCenterY(rotY); }
Example 14
Source File: TimeZoneRulesImplTest.java From questdb with Apache License 2.0 | 5 votes |
@Test public void testSingle() { ZoneId zone = ZoneId.of("GMT"); TimeZoneRulesImpl rules = new TimeZoneRulesImpl(zone.getRules()); int y = 2017; int m = 3; int d = 29; LocalDateTime dt = LocalDateTime.of(y, m, d, 0, 0); long millis = Timestamps.toMicros(y, m, d, 0, 0); ZonedDateTime zdt = dt.atZone(zone); long expected = zdt.getOffset().getTotalSeconds(); // find out how much algo added to datetime itself long changed = Timestamps.toMicros(zdt.getYear(), zdt.getMonthValue(), zdt.getDayOfMonth(), zdt.getHour(), zdt.getMinute()) + zdt.getSecond() * 1000; // add any extra time expected += (changed - millis) / 1000; long offset = rules.getOffset(millis, y, Timestamps.isLeapYear(y)); try { Assert.assertEquals(expected, offset / 1000); } catch (Throwable e) { System.out.println(zone.getId() + "; " + zdt + "; " + Timestamps.toString(millis + offset)); throw e; } }
Example 15
Source File: JavatimeTest.java From jdk8u-dev-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 16
Source File: JavatimeTest.java From jdk8u60 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 17
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 18
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); } }
Example 19
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 20
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); } }