/** * Gets the property object for the specified type, which contains many useful methods. * * @param type the field type to get the chronology for * @return the property object * @throws IllegalArgumentException if the field is null or unsupported * @since 1.2 */ public Property property(DateTimeFieldType type) { if (type == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } DateTimeField field = type.getField(getChronology()); if (field.isSupported() == false) { throw new IllegalArgumentException("Field '" + type + "' is not supported"); } return new Property(this, field); }
@Test( dataProvider = "samples", groups = {"tck"}) public void test_samples_set(DateTimeField field, LocalDate date, long value) { assertEquals(field.doSet(LocalDate.MAX_DATE, value), date); assertEquals(field.doSet(LocalDate.MIN_DATE, value), date); assertEquals(field.doSet(JAN01_1970, value), date); assertEquals(field.doSet(DEC31_1969, value), date); assertEquals(field.doSet(NOV12_1945, value), date); }
@Override public void parse(String field, Data data) { // Skip truncated data if (!DATE_TIME_PTN.matcher(field).matches()) return; // skip parse() if DATETIME has been parsed from INFO if (data.strDate.length() == 0) super.parse(field, data); }
/** FieldChanged Method. */ public int fieldChanged(boolean bDisplayOption, int iMoveMode) { BaseField fldDays = this.getOwner(); BookingCar recBookingCar = (BookingCar) fldDays.getRecord(); DateTimeField fldStartDate = (DateTimeField) recBookingCar.getField(BookingCar.DETAIL_DATE); if ((!fldStartDate.isNull()) && (fldDays.getValue() > 0)) { Date dateStart = fldStartDate.getDateTime(); float fDays = (float) fldDays.getValue(); Date dateEnd = new Date(dateStart.getTime() + (long) (fDays * DBConstants.KMS_IN_A_DAY)); Calendar calendar = DateTimeField.m_calendar; calendar.setTime(dateEnd); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); dateEnd = calendar.getTime(); DateTimeField fldEndDate = (DateTimeField) recBookingCar.getField(BookingCar.DETAIL_END_DATE); return fldEndDate.setDateTime(dateEnd, bDisplayOption, iMoveMode); } return super.fieldChanged(bDisplayOption, iMoveMode); }
/** * Set the milliseconds of the datetime. * * <p>All changes to the millisecond field occurs via this method. * * @param instant the milliseconds since 1970-01-01T00:00:00Z to set the datetime to */ public void setMillis(long instant) { switch (iRoundingMode) { case ROUND_NONE: break; case ROUND_FLOOR: instant = iRoundingField.roundFloor(instant); break; case ROUND_CEILING: instant = iRoundingField.roundCeiling(instant); break; case ROUND_HALF_FLOOR: instant = iRoundingField.roundHalfFloor(instant); break; case ROUND_HALF_CEILING: instant = iRoundingField.roundHalfCeiling(instant); break; case ROUND_HALF_EVEN: instant = iRoundingField.roundHalfEven(instant); break; } super.setMillis(instant); }
@Override public void parse(String field, Data data) { if (data.strDate.length() == 0) { super.parse(field, data); } }
@Override public void convertInput() { Date modelObject = (Date) getDefaultModelObject(); getDateTextField().setConvertedInput(modelObject != null ? modelObject : newDateInstance()); super.convertInput(); }
/** Writes the property in a safe serialization format. */ private void writeObject(ObjectOutputStream oos) throws IOException { oos.writeObject(iInstant); oos.writeObject(iField.getType()); }