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 ZonedDateTime withYear(int value) { return dt.withYear(value); }
public ZonedDateTime withYear(int value) { return dt.withYear(value); }
public ZonedDateTime withYear(int value) { return dt.withYear(value); }
/** * ZonedDateTime型からTime型に変換します * * @param dateTime * @return カレンダー型 */ private java.sql.Time toTime(final ZonedDateTime dateTime) { if (dateTime == null) { return null; } java.sql.Time time=new java.sql.Time(dateTime.withZoneSameInstant(AbstractJava8DateConverter.INSTANT_ZONE_ID) .withYear(1970).withMonth(1).withDayOfMonth(1).toInstant().toEpochMilli()); return time; }
/** * NOTE: Code-generation-invoked method, method name and parameter order matters * * @param zdt zoneddatetime * @param year year * @param month month * @param day day * @return ldt */ public static ZonedDateTime actionSetYMDZonedDateTime(ZonedDateTime zdt, Integer year, Integer month, Integer day) { if (year != null) { zdt = zdt.withYear(year); } if (month != null) { zdt = zdt.withMonth(month); } if (day != null) { zdt = zdt.withDayOfMonth(day); } return zdt; }
@Override public Instant instant() { ZonedDateTime dt = ZonedDateTime.now(zone); if (year != null) dt = dt.withYear(year); if (month != null) dt = dt.withMonth(month); if (day != null) dt = dt.withDayOfMonth(day); if (hour != null) dt = dt.withHour(hour); if (min != null) dt = dt.withMinute(min); if (sec != null) dt = dt.withSecond(sec); return dt.toInstant(); }
private static Object convertOutput(Context context, Type type, ZonedDateTime dateTime, Class<?> targetClass, Calendar targetCalendar) throws ConversionException { if (targetClass == OffsetDateTime.class) { return dateTime.toOffsetDateTime(); } if (targetClass == String.class) { return context.getTimestampFormat().getPrinter().format(dateTime); } ZoneId targetZoneId = targetCalendar.getTimeZone().toZoneId(); ZonedDateTime zonedDateTime = dateTime.withZoneSameInstant(targetZoneId); if (targetClass == Time.class) { return new Time(zonedDateTime.withYear(1970).withDayOfYear(1).toInstant().toEpochMilli()); } if (targetClass == Date.class) { return new Date(zonedDateTime.truncatedTo(ChronoUnit.DAYS).toInstant().toEpochMilli()); } if (targetClass == Timestamp.class) { return Timestamp.from(zonedDateTime.toInstant()); } throw new ConversionException(type, targetClass); }
private static Object convertOutput(Context context, Type type, LocalDateTime dateTime, Class<?> targetClass, Calendar targetCalendar) throws ConversionException { if (targetClass == LocalDateTime.class) { return dateTime; } if (targetClass == LocalDate.class) { return dateTime.toLocalDate(); } if (targetClass == String.class) { return context.getTimestampFormat().getPrinter().format(dateTime); } ZoneId targetZoneId = targetCalendar.getTimeZone().toZoneId(); ZonedDateTime zonedDateTime = dateTime.atOffset(ZoneOffset.UTC).atZoneSimilarLocal(targetZoneId); if (targetClass == Time.class) { return new Time(zonedDateTime.withYear(1970).withDayOfYear(1).toInstant().toEpochMilli()); } if (targetClass == Date.class) { return new Date(zonedDateTime.truncatedTo(ChronoUnit.DAYS).toInstant().toEpochMilli()); } if (targetClass == Timestamp.class) { return Timestamp.from(zonedDateTime.toInstant()); } throw new ConversionException(type, targetClass); }
zdt = zdt.withYear(1997); parseCompareDate(zdt, "1997", "yyyyMMdd");