Java Code Examples for java.time.ZonedDateTime#getDayOfMonth()
The following examples show how to use
java.time.ZonedDateTime#getDayOfMonth() .
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: 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 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: IncrementalTimeConverterUtil.java From siddhi with Apache License 2.0 | 6 votes |
private static long getNextEmitTimeForDay(long currentTime, String timeZone) { ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(currentTime), ZoneId.of(timeZone)); if (zonedDateTime.getDayOfMonth() + 1 > zonedDateTime.getMonth().length(zonedDateTime.getYear() % 4 == 0)) { // if the current day is the last day of the month if (zonedDateTime.getMonthValue() == 12) { // For a time in December, emit time should be beginning of January next year return ZonedDateTime .of(zonedDateTime.getYear() + 1, 1, 1, 0, 0, 0, 0, ZoneId.of(timeZone)) .toEpochSecond() * 1000; } else { // For any other month, the 1st day of next month must be considered return ZonedDateTime.of(zonedDateTime.getYear(), zonedDateTime.getMonthValue() + 1, 1, 0, 0, 0, 0, ZoneId.of(timeZone)).toEpochSecond() * 1000; } } else { // for any other days return ZonedDateTime .of(zonedDateTime.getYear(), zonedDateTime.getMonthValue(), zonedDateTime.getDayOfMonth() + 1, 0, 0, 0, 0, ZoneId.of(timeZone)).toEpochSecond() * 1000; } }
Example 4
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 5
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 6
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 7
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 8
Source File: WallClockTimeImpl.java From ttt with BSD 2-Clause "Simplified" License | 5 votes |
/** * Obtain current wall clock time in UTC time zone * @return current wall clock time in UTC time zone */ public static WallClockTime utc() { ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")); int years = now.getYear(); int months = now.getMonthValue(); int days = now.getDayOfMonth(); int hours = now.getHour(); int minutes = now.getMinute(); double seconds = (double) now.getSecond() + ((double) now.getNano()) / 1e9; return new WallClockTimeImpl(years, months, days, hours, minutes, seconds); }
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-jdk9 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-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 12
Source File: JavatimeTest.java From openjdk-jdk8u 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: ZonedDateTimeAxis.java From constellation with Apache License 2.0 | 5 votes |
@Override protected String getTickMarkLabel(ZonedDateTime datetime) { final StringConverter<ZonedDateTime> converter = getTickLabelFormatter(); if (converter != null) { return converter.toString(datetime); } final DateTimeFormatter formatter; if (actualInterval.interval == ChronoUnit.YEARS && datetime.getMonth() == Month.JANUARY && datetime.getDayOfMonth() == 1) { formatter = DateTimeFormatter.ofPattern("yyyy"); } else if (actualInterval.interval == ChronoUnit.MONTHS && datetime.getDayOfMonth() == 1) { formatter = DateTimeFormatter.ofPattern("MMM yy"); } else { switch (actualInterval.interval) { case DAYS: case WEEKS: case HOURS: case MINUTES: formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT); break; case SECONDS: formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); break; case MILLIS: formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL); break; default: formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM); break; } } return formatter.format(datetime); }
Example 14
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 15
Source File: DateParseFunction.java From vertexium with Apache License 2.0 | 5 votes |
protected Object fromMap(VertexiumCypherQueryContext ctx, Map map) { Number year = (Number) map.get("year"); Number month = (Number) map.get("month"); Number day = (Number) map.get("day"); Number hour = (Number) map.get("hour"); Number minute = (Number) map.get("minute"); Number second = (Number) map.get("second"); String timeZone = (String) map.get("timezone"); ZoneId zoneId; if (timeZone == null) { zoneId = ctx.getZoneId(); } else { zoneId = ZoneId.of(timeZone); } ZonedDateTime now = ctx.getNow(); int yearInt = year == null ? now.getYear() : year.intValue(); int monthInt = month == null ? now.getMonthValue() : month.intValue(); int dayInt = day == null ? now.getDayOfMonth() : day.intValue(); int hourInt = hour == null ? 0 : hour.intValue(); int minuteInt = minute == null ? 0 : minute.intValue(); int secondInt = second == null ? 0 : second.intValue(); return ZonedDateTime.of( yearInt, monthInt, dayInt, hourInt, minuteInt, secondInt, 0, zoneId ); }
Example 16
Source File: IncrementalTimeConverterUtil.java From siddhi with Apache License 2.0 | 5 votes |
private static long getNextEmitTimeForHour(long currentTime, String timeZone) { ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(currentTime), ZoneId.of(timeZone)); if (zonedDateTime.getHour() == 23) { if (zonedDateTime.getDayOfMonth() + 1 > zonedDateTime.getMonth().length(zonedDateTime.getYear() % 4 == 0)) { // if the current day is the last day of the month if (zonedDateTime.getMonthValue() == 12) { // For a time in December, emit time should be beginning of January next year return ZonedDateTime .of(zonedDateTime.getYear() + 1, 1, 1, 0, 0, 0, 0, ZoneId.of(timeZone)) .toEpochSecond() * 1000; } else { // For any other month, the 1st day of next month must be considered return ZonedDateTime.of(zonedDateTime.getYear(), zonedDateTime.getMonthValue() + 1, 1, 0, 0, 0, 0, ZoneId.of(timeZone)).toEpochSecond() * 1000; } } else { // for any other days return ZonedDateTime .of(zonedDateTime.getYear(), zonedDateTime.getMonthValue(), zonedDateTime.getDayOfMonth() + 1, 0, 0, 0, 0, ZoneId.of(timeZone)).toEpochSecond() * 1000; } } else { return ZonedDateTime .of(zonedDateTime.getYear(), zonedDateTime.getMonthValue(), zonedDateTime.getDayOfMonth(), zonedDateTime.getHour() + 1, 0, 0, 0, ZoneId.of(timeZone)).toEpochSecond() * 1000; } }
Example 17
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 18
Source File: DayFunction.java From vertexium with Apache License 2.0 | 4 votes |
@Override protected Object invokeZonedDateTime(VertexiumCypherQueryContext ctx, ZonedDateTime date) { return date.getDayOfMonth(); }
Example 19
Source File: CalendarTileSkin.java From OEE-Designer with MIT License | 4 votes |
private void drawCells() { List<ChartData> dataList = tile.getChartData(); ZonedDateTime time = tile.getTime(); Locale locale = tile.getLocale(); int day = time.getDayOfMonth(); int startDay = time.withDayOfMonth(1).getDayOfWeek().getValue(); long lastDay = time.range(DAY_OF_MONTH).getMaximum(); Color textColor = tile.getTextColor(); Color bkgColor = tile.getBackgroundColor(); Font regFont = Fonts.latoRegular(size * 0.045); Font bldFont = Fonts.latoBold(size * 0.045); Background bkgToday = new Background(new BackgroundFill(tile.getBarColor(), new CornerRadii(size * 0.0125), new Insets(2))); Border appmntBorder = new Border(new BorderStroke(tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), tile.getAlarmColor(), BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, BorderStrokeStyle.SOLID, new CornerRadii(size * 0.0125), BorderWidths.DEFAULT, new Insets(1))); boolean counting = false; int dayCounter = 1; for (int y = 0 ; y < 7 ; y++) { for (int x = 0 ; x < 8 ; x++) { int index = y * 8 + x; Label label = labels.get(index); String text; if (x == 0 && y == 0) { text = ""; label.setManaged(false); label.setVisible(false); } else if (y == 0) { text = DayOfWeek.of(x).getDisplayName(TextStyle.SHORT, locale); //label.setTextFill(x == 7 ? Tile.RED : textColor); label.setTextFill(textColor); label.setFont(bldFont); } else if (x == 0) { text = Integer.toString(time.withDayOfMonth(1).plusDays((y - 1) * 7).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR)); label.setTextFill(Tile.GRAY); label.setFont(regFont); label.setBorder(weekBorder); } else { if (index - 7 > startDay) { counting = true; text = Integer.toString(dayCounter); LocalDate currentDay = time.toLocalDate().plusDays(dayCounter - 1); long appointments = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(currentDay)).count(); if (x == 7) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(Tile.RED); label.setFont(regFont); } else if (dayCounter == day) { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setBackground(bkgToday); label.setTextFill(bkgColor); label.setFont(bldFont); } else { if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); } label.setTextFill(textColor); label.setFont(regFont); } } else { text = ""; label.setManaged(false); label.setVisible(false); } if (dayCounter > lastDay) { text = ""; label.setManaged(false); label.setVisible(false); } if (counting) { dayCounter++; } } label.setText(text); label.setVisible(true); label.setManaged(true); label.setPrefSize(cellWidth, cellHeight); label.relocate(x * cellWidth + cellOffsetX, y * cellHeight + cellOffsetY); } } }
Example 20
Source File: ZonedDateTimeExtractYearMonthDayIntegerValues.java From tutorials with MIT License | 4 votes |
int getDay(ZonedDateTime zonedDateTime) { return zonedDateTime.getDayOfMonth(); }