@Override public LocalDate convertFrom(LocalDate localDate, Type<LocalDate> type, MappingContext mappingContext) { return LocalDate.from(localDate); } }
@Override public LocalDate convertTo(LocalDate localDate, Type<LocalDate> type, MappingContext mappingContext) { return LocalDate.from(localDate); }
@Override public LocalDate fromString(String string) { return LocalDate.from( LocalDateType.FORMATTER.parse( string ) ); }
/** * Converts a string object for an object type of {@link LocalDate}. * If the column definition allows null and default value is 0000-00-00, we need return null; * else 0000-00-00 will be replaced with 1970-01-01; * * @param column the column definition describing the {@code data} value; never null * @param value the string object to be converted into a {@link LocalDate} type; * @return the converted value; */ private Object convertToLocalDate(Column column, String value) { final boolean zero = EPOCH_EQUIVALENT_DATE.matcher(value).matches() || "0".equals(value); if (zero && column.isOptional()) { return null; } if (zero) { value = EPOCH_DATE; } return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(value)); }
private static long epochDaysInZone(TimeZoneKey timeZoneKey, long instant) { return LocalDate.from(Instant.ofEpochMilli(instant).atZone(ZoneId.of(timeZoneKey.getId()))).toEpochDay(); }
/** * Copy constructor. * * @param entity Entity to copy from. */ EntityWithDateTimeFields(EntityWithDateTimeFields entity) { id = entity.id; locTime = LocalTime.from(entity.locTime); locDate = LocalDate.from(entity.locDate); locDateTime = LocalDateTime.from(entity.locDateTime); }
LocalDate localDate = LocalDate.from(accessor); LocalTime localTime; ZoneId zoneId;
@Override protected LocalDate toType(TemporalAccessor temporalAccessor) { return temporalAccessor == null ? null : LocalDate.from(temporalAccessor); } }
Instant instant = LocalDate.from(accessor).atStartOfDay().toInstant(ZoneOffset.UTC); assertThat(schemaA.defaultValue()).isEqualTo(java.util.Date.from(instant));
dateFromDefault = LocalDate.from(given); } else { final int year;
@Override public LocalDate read(final String data) { try { return LocalDate.parse(data, CTLocalDateTransformer.DATETIME_FORMATTER); } catch (final IllegalArgumentException e) { return LocalDate.from(CTLocalDateTransformer.SIMPLE_DATE_FORMATTER.parse(data)); } }
/** * @param folderName * @return * @throws DateTimeParseException */ final static long parseCompatibilityFolderName(final String folderName) { return ZonedDateTime.of(LocalDate.from(formatter.parse(folderName)), LocalTime.MIN, zone).toInstant().toEpochMilli(); }
@Override protected Object transformFromSource(Object value) { if (Strings.isEmpty(value)) { return null; } String valueAsString = (String) value; if (valueAsString.contains("+")) { return LocalDate.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(valueAsString)); } else { return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(valueAsString)); } }
@Override protected Object transformFromElastic(Value object) { String valueAsString = object.asString(); if (Strings.isEmpty(valueAsString)) { return null; } if (valueAsString.contains("+")) { return LocalDate.from(DateTimeFormatter.ISO_OFFSET_DATE.parse(valueAsString)); } else { return LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse(valueAsString)); } }
@Override protected LocalDateTime convert2Target(DateTimeFormatter formatter, String obj) { TemporalAccessor temporal = formatter.parse(obj); try { return LocalDateTime.from(temporal); } catch (DateTimeException ex) { // a local date only string return LocalDate.from(temporal).atStartOfDay(); } }
public boolean doWeQueryAgainDayBased(Metric queriedMetric) { if (null == queriedMetric) { //never queried before return true; } LocalDate lastCalled = LocalDate.from(queriedMetric.getLastCalledDate().toInstant().atZone(ZoneId.systemDefault())); LocalDate todayDate = LocalDate.now(ZoneId.systemDefault()); if(!lastCalled.equals(todayDate)) { return true; } else { return false; } }
private String getDateString(boolean dateTime) { if (date == null) { return ""; } if (dateTime) { return NLS.toUserString(date); } else { return NLS.toUserString(LocalDate.from(date)); } }
@Override public long getFrom(TemporalAccessor temporal) { if (temporal.isSupported(this) == false) { throw new UnsupportedTemporalTypeException("Unsupported field: WeekOfWeekBasedYear"); } return getWeek(LocalDate.from(temporal)); } @SuppressWarnings("unchecked")
} else if (accessor.isSupported(WeekFields.ISO.weekBasedYear())) { if (accessor.isSupported(WeekFields.ISO.weekOfWeekBasedYear())) { return LocalDate.from(result) .with(WeekFields.ISO.weekBasedYear(), accessor.getLong(WeekFields.ISO.weekBasedYear())) .withDayOfMonth(1) // makes this compatible with joda .atStartOfDay(ZoneOffset.UTC); } else { return LocalDate.from(result) .with(WeekFields.ISO.weekBasedYear(), accessor.getLong(WeekFields.ISO.weekBasedYear()))
public FEELFnResult<TemporalAccessor> invoke(@ParameterName("from") TemporalAccessor date) { if (date == null) { return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "cannot be null")); } try { return FEELFnResult.ofResult(LocalDate.from(date)); } catch (DateTimeException e) { return FEELFnResult.ofError(new InvalidParametersEvent(FEELEvent.Severity.ERROR, "from", "date-parsing exception", e)); } } }