private Date convertToDate(Object object) { final long millis; if (object instanceof Integer) { final Integer value = (Integer) object; // adopted from Apache Calcite final long t = (long) value * 86400000L; millis = t - (long) LOCAL_TZ.getOffset(t); } else { // use 'provided' Joda time final LocalDate value = (LocalDate) object; millis = value.toDate().getTime(); } return new Date(millis); }
@Override public java.sql.Date getPrimitiveJavaObject(Object o) { final DateHolder h = (DateHolder) o; org.joda.time.LocalDate localDate = new org.joda.time.LocalDate(h.value, org.joda.time.DateTimeZone.UTC); // Use "toDate()" to get java.util.Date object with exactly the same year the same year, month and day as Joda date. // See more in Javadoc for "LocalDate#toDate()" return new java.sql.Date(localDate.toDate().getTime()); }
@Override public java.sql.Date getPrimitiveJavaObject(Object o) { if (o == null) { return null; } final NullableDateHolder h = (NullableDateHolder) o; org.joda.time.LocalDate localDate = new org.joda.time.LocalDate(h.value, org.joda.time.DateTimeZone.UTC); // Use "toDate()" to get java.util.Date object with exactly the same year the same year, month and day as Joda date. // See more in Javadoc for "LocalDate#toDate()" return new java.sql.Date(localDate.toDate().getTime()); }
@Override public List<RolledUpUsageModelDao> getAllUsageForSubscription(final UUID subscriptionId, final LocalDate startDate, final LocalDate endDate, final InternalTenantContext context) { return dbRouter.onDemand(true).getAllUsageForSubscription(subscriptionId, startDate.toDate(), endDate.toDate(), context); }
@Override public DateWritable getPrimitiveWritableObject(Object o) { if (o == null) { return null; } final NullableDateHolder h = (NullableDateHolder) o; org.joda.time.LocalDate localDate = new org.joda.time.LocalDate(h.value, org.joda.time.DateTimeZone.UTC); // Use "toDate()" to get java.util.Date object with exactly the same year the same year, month and day as Joda date. // See more in Javadoc for "LocalDate#toDate()" return new DateWritable(new java.sql.Date(localDate.toDate().getTime())); }
@Override public DateWritable getPrimitiveWritableObject(Object o) { final DateHolder h = (DateHolder) o; org.joda.time.LocalDate localDate = new org.joda.time.LocalDate(h.value, org.joda.time.DateTimeZone.UTC); // Use "toDate()" to get java.util.Date object with exactly the same year the same year, month and day as Joda date. // See more in Javadoc for "LocalDate#toDate()" return new DateWritable(new java.sql.Date(localDate.toDate().getTime())); }
@Override public List<RolledUpUsageModelDao> getUsageForSubscription(final UUID subscriptionId, final LocalDate startDate, final LocalDate endDate, final String unitType, final InternalTenantContext context) { return dbRouter.onDemand(true).getUsageForSubscription(subscriptionId, startDate.toDate(), endDate.toDate(), unitType, context); }
assertEquals(LocalDate.parse("2009-10-31").toDate(), handler.date); assertEquals(Double.valueOf(0.9999), handler.percent);
@Override public Date convert(LocalDate in, Context context) throws Exception { if (in == null) return null; return in.toDate(); } }
@Override void write(Cell cell) { cell.setCellType(Cell.CELL_TYPE_NUMERIC); LocalDate cellValue = date; if (cellValue != null) { Date value = cellValue.toDate(); cell.setCellValue(value); } }
/** * get$dateOfNextYear * * @return a {@link java.util.Date} object. */ public Date get$dateOfNextYear(){ LocalDate dt = new LocalDate(); return dt.plusYears(1).toDate(); }
public ReflexDateValue add(Object increase) { if (increase instanceof Integer) { int amountToIncrease = ((Integer) increase).intValue(); return new ReflexDateValue(calHandler.addDays(date.toDate(), amountToIncrease), calendarString); } else { throw new ReflexException(-1, "Cannot increase a date by something of type " + increase.getClass().toString()); } }
public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { if (value == null) { StandardBasicTypes.DATE.nullSafeSet(preparedStatement, null, index); } else { StandardBasicTypes.DATE.nullSafeSet(preparedStatement, ((LocalDate) value).toDate(), index); } }
@Override void apachePOI(POICell cell, Object value) { if (value != null) { LocalDate val = (LocalDate) value; cell.setCellType(Cell.CELL_TYPE_NUMERIC); cell.setCellValue(val.toDate()); } }
@Override public void setWritableCell(TableModel tableModel, XSSFCell cell, Object value, int row, int col) { LocalDate localDate = (LocalDate) value; cell.setCellStyle(cellStyle); if (localDate != null) { cell.setCellValue(localDate.toDate()); } } }
public static Date addDate(Object startDate, Object years, Object months, Object days) { LocalDate currentDate = new LocalDate(startDate); currentDate = currentDate.plusYears(intValue(years)); currentDate = currentDate.plusMonths(intValue(months)); currentDate = currentDate.plusDays(intValue(days)); return currentDate.toDate(); }
@Override public void scheduleDayOfWeekJob(DayOfWeekSchedulableJob dayOfWeekSchedulableJob) { logObjectIfNotNull(dayOfWeekSchedulableJob); MotechEvent motechEvent = dayOfWeekSchedulableJob.getMotechEvent(); LocalDate start = dayOfWeekSchedulableJob.getStartDate(); LocalDate end = dayOfWeekSchedulableJob.getEndDate(); Time time = dayOfWeekSchedulableJob.getTime(); CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.atHourAndMinuteOnGivenDaysOfWeek(time.getHour(), time.getMinute(), dayOfWeekSchedulableJob.getCronDays().toArray(new Integer[0])); CronTriggerImpl cronTrigger = (CronTriggerImpl) cronScheduleBuilder.build(); CronSchedulableJob cronSchedulableJob = new CronSchedulableJob(motechEvent, cronTrigger.getCronExpression(), start.toDate(), end.toDate(), dayOfWeekSchedulableJob.isIgnorePastFiresAtStart()); scheduleJob(cronSchedulableJob); }
private void setUpProgressForDayRow(final FormComponent progressForDayRowForm, final OrderRealizationDay realizationDay) { FieldComponent dayField = progressForDayRowForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF); FieldComponent dateField = progressForDayRowForm.findFieldComponentByName(DATE_INPUT_REF); dayField.setFieldValue(realizationDay.getRealizationDayNumber()); dateField.setFieldValue(DateUtils.toDateString(realizationDay.getDate().toDate())); AwesomeDynamicListComponent dailyProgressADL = (AwesomeDynamicListComponent) progressForDayRowForm .findFieldComponentByName(DAILY_PROGRESS_ADL_REF); dailyProgressADL.setFieldValue(fillDailyProgressWithShifts(realizationDay.getWorkingShifts())); }