private ZonedDateTime adjustToStartDate(ZonedDateTime zonedStartAt, ZonedDateTime zonedNow, ZoneId zoneId) { if (durationType == ReportDurationType.CUSTOM) { ZonedDateTime zonedStartDate = getZonedFromTs(startTs, zoneId).with(LocalTime.MIN); if (zonedStartDate.isAfter(zonedNow)) { zonedStartAt = zonedStartAt .withDayOfMonth(zonedStartDate.getDayOfMonth()) .withMonth(zonedStartDate.getMonthValue()) .withYear(zonedStartDate.getYear()); } } return zonedStartAt; }
public int getMonthValue() { return dt.getMonthValue(); }
@Deprecated public int getMonthOfYear() { logDeprecatedMethod("getMonthOfYear()", "getMonthValue()"); return dt.getMonthValue(); }
@SuppressWarnings("deprecation") @Override public int getMonth() { return date.getMonthValue(); }
private void assertTimeZoneDate(ZonedDateTime openingDate) { assertEquals(openingDate.getYear(), YEAR); assertEquals(openingDate.getMonthValue(), MONTH); assertEquals(openingDate.getDayOfMonth(), DAY); }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) { output.writeInt(zonedDateTime.getYear()); output.writeInt(zonedDateTime.getMonthValue()); output.writeInt(zonedDateTime.getDayOfMonth()); output.writeInt(zonedDateTime.getHour()); output.writeInt(zonedDateTime.getMinute()); output.writeInt(zonedDateTime.getSecond()); output.writeInt(zonedDateTime.getNano()); output.writeString(zonedDateTime.getZone().getId()); }
/** * Converts a {@link ZonedDateTime} to Month in year. * <p> * January is 1, February is 2, and so on. * </p> * @param date to extract month. * @return month. */ public static int MONTH(ZonedDateTime date) { validate(date, "MONTH"); return date.getMonthValue(); }
@Deprecated public int getMonthOfYear() { logDeprecatedMethod("getMonthOfYear()", "getMonthValue()"); return dt.getMonthValue(); }
ZoneId zoneId = ZoneId.of( "Europe/Paris" ); ZonedDateTime now = ZonedDateTime.now( zoneId ); int dayOfMonth = now.getDayOfMonth(); int monthOfYear = now.getMonthValue(); // 1-based counting, January = 1, unlike java.util.Calendar. String nowAsString = DateTimeFormatter.ofLocalizedDate( FormatStyle.FULL ).withLocale( Locale.FRANCE ).format( now );
@Deprecated public int getMonthOfYear() { logDeprecatedMethod("getMonthOfYear()", "getMonthValue()"); return dt.getMonthValue(); }
private TimeNode generateDayCandidatesUsingDoM(final ZonedDateTime reference) { final LocalDate date = LocalDate.of(reference.getYear(), reference.getMonthValue(), 1); final int lengthOfMonth = date.lengthOfMonth(); final List<Integer> candidates = createDayOfMonthValueGeneratorInstance(daysOfMonthCronField, reference.getYear(), reference.getMonthValue()) .generateCandidates(1, lengthOfMonth) .stream().distinct().sorted() .collect(Collectors.toList()); return new TimeNode(candidates); }
@Test public void renamingToArbitraryMethodName() throws Exception { ZonedDateTime current = ZonedDateTime.now(); ZonedDateTime mockMidNight = ZonedDateTime.of(current.getYear(), current.getMonthValue(), current.getDayOfMonth(), 0, 0, 0, 0, ZoneId.of("US/Eastern")); PowerMockito.mockStatic(ZonedDateTime.class); PowerMockito.when(ZonedDateTime.ofInstant(anyObject(), anyObject())).thenReturn(mockTime); }
private static long getStartTimeOfAggregatesForMonth(long currentTime, String timeZone) { ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(currentTime), ZoneId.ofOffset("GMT", ZoneOffset.of(timeZone))); return ZonedDateTime.of(zonedDateTime.getYear(), zonedDateTime.getMonthValue(), 1, 0, 0, 0, 0, ZoneId.ofOffset("GMT", ZoneOffset.of(timeZone))).toEpochSecond() * 1000; }
DayIndexKey(ZonedDateTime dateTime) { this.dateTime = MeteoDateUtils.toZeroHMSN(dateTime); this.day = dateTime.getDayOfMonth(); this.month = dateTime.getMonthValue(); this.year = dateTime.getYear(); } }
private boolean isDateMatch(ZonedDateTime requestedDate, ZonedDateTime actualDate) { return requestedDate.getYear() == actualDate.getYear() && requestedDate.getMonthValue() == actualDate.getMonthValue() && requestedDate.getDayOfMonth() == actualDate.getDayOfMonth() && requestedDate.getHour() == actualDate.getHour(); }
public ZonedDateTime toFirstDate(ZonedDateTime date) { return (date == null) ? null : ZonedDateTime.of(date.getYear(), date.getMonthValue(), 1, date.getHour(), date.getMinute(), date.getSecond(), date.getNano(), date.getZone()); } }
public ZonedDateTime toLastDate(ZonedDateTime date) { YearMonth yearMonth = toYearMonth(date); int lastDayOfMonth = yearMonth.lengthOfMonth(); return (date == null) ? null : ZonedDateTime.of(date.getYear(), date.getMonthValue(), lastDayOfMonth, date.getHour(), date.getMinute(), date.getSecond(), date.getNano(), date.getZone()); }
static DateValue zonedDateTimeToDateValue(ZonedDateTime dt) { return new DateTimeValueImpl( dt.getYear(), dt.getMonthValue(), dt.getDayOfMonth(), dt.getHour(), dt.getMinute(), dt.getSecond()); }
private void assertTimeZoneDate(ZonedDateTime openingDate) { assertEquals(openingDate.getYear(), YEAR); assertEquals(openingDate.getMonthValue(), MONTH); assertEquals(openingDate.getDayOfMonth(), DAY); }
@Override public <O extends OutputShim> void write(final KryoShim<?, O> kryo, final O output, final ZonedDateTime zonedDateTime) { output.writeInt(zonedDateTime.getYear()); output.writeInt(zonedDateTime.getMonthValue()); output.writeInt(zonedDateTime.getDayOfMonth()); output.writeInt(zonedDateTime.getHour()); output.writeInt(zonedDateTime.getMinute()); output.writeInt(zonedDateTime.getSecond()); output.writeInt(zonedDateTime.getNano()); output.writeString(zonedDateTime.getZone().getId()); }