/** * Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z * using the specified chronology. * <p> * If the chronology is null, <code>ISOChronology</code> * in the default time zone is used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public BaseDateTime(long instant, Chronology chronology) { super(); iChronology = checkChronology(chronology); iMillis = checkInstant(instant, iChronology); adjustForMinMax(); }
/** * Set the chronology of the datetime. * <p> * All changes to the chronology occur via this method. * * @param chronology the chronology to use, null means ISOChronology in default zone */ public void setChronology(Chronology chronology) { super.setChronology(chronology); }
/** * Get this object as a DateTime, returning <code>this</code> if possible. * * @param zone time zone to apply, or default if null * @return a DateTime using the same millis */ public DateTime toDateTime(DateTimeZone zone) { zone = DateTimeUtils.getZone(zone); if (getZone() == zone) { return this; } return super.toDateTime(zone); }
/** * Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z * using the specified chronology. * <p> * If the chronology is null, <code>ISOChronology</code> * in the default time zone is used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public BaseDateTime(long instant, Chronology chronology) { super(); iChronology = checkChronology(chronology); iMillis = checkInstant(instant, iChronology); }
/** * Sets the chronology of the datetime. * <p> * All changes to the chronology field occurs via this method. * Override and block this method to make a subclass immutable. * * @param chronology the chronology to set */ protected void setChronology(Chronology chronology) { iChronology = checkChronology(chronology); }
/** * Sets the milliseconds of the datetime. * <p> * All changes to the millisecond field occurs via this method. * Override and block this method to make a subclass immutable. * * @param instant the milliseconds since 1970-01-01T00:00:00Z to set the datetime to */ protected void setMillis(long instant) { iMillis = checkInstant(instant, iChronology); }
/** * Get this object as a DateTime using ISOChronology in the default zone, * returning <code>this</code> if possible. * * @return a DateTime using the same millis */ public DateTime toDateTimeISO() { if (getChronology() == ISOChronology.getInstance()) { return this; } return super.toDateTimeISO(); }
/** * 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); }
/** * Constructs an instance from an Object that represents a datetime, * using the specified chronology. * <p> * If the chronology is null, ISO in the default time zone is used. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * * @param instant the datetime object * @param chronology the chronology * @throws IllegalArgumentException if the instant is invalid */ public BaseDateTime(Object instant, Chronology chronology) { super(); InstantConverter converter = ConverterManager.getInstance().getInstantConverter(instant); iChronology = checkChronology(converter.getChronology(instant, chronology)); iMillis = checkInstant(converter.getInstantMillis(instant, chronology), iChronology); }
/** * Sets the chronology of the datetime. * <p> * All changes to the chronology field occurs via this method. * Override and block this method to make a subclass immutable. * * @param chronology the chronology to set */ protected void setChronology(Chronology chronology) { iChronology = checkChronology(chronology); }
/** * Sets the milliseconds of the datetime. * <p> * All changes to the millisecond field occurs via this method. * Override and block this method to make a subclass immutable. * * @param instant the milliseconds since 1970-01-01T00:00:00Z to set the datetime to */ protected void setMillis(long instant) { iMillis = checkInstant(instant, iChronology); }
/** * Get this object as a DateTime using ISOChronology in the default zone, * returning <code>this</code> if possible. * * @return a DateTime using the same millis */ public DateTime toDateTimeISO() { if (getChronology() == ISOChronology.getInstance()) { return this; } return super.toDateTimeISO(); }
/** * 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); }
/** * Constructs an instance from an Object that represents a datetime, * forcing the time zone to that specified. * <p> * If the object contains no chronology, <code>ISOChronology</code> is used. * If the specified time zone is null, the default zone is used. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * * @param instant the datetime object * @param zone the time zone * @throws IllegalArgumentException if the instant is invalid */ public BaseDateTime(Object instant, DateTimeZone zone) { super(); InstantConverter converter = ConverterManager.getInstance().getInstantConverter(instant); Chronology chrono = checkChronology(converter.getChronology(instant, zone)); iChronology = chrono; iMillis = checkInstant(converter.getInstantMillis(instant, chrono), chrono); }
/** * Constructs an instance set to the milliseconds from 1970-01-01T00:00:00Z * using the specified chronology. * <p> * If the chronology is null, <code>ISOChronology</code> * in the default time zone is used. * * @param instant the milliseconds from 1970-01-01T00:00:00Z * @param chronology the chronology, null means ISOChronology in default zone */ public BaseDateTime(long instant, Chronology chronology) { super(); iChronology = checkChronology(chronology); iMillis = checkInstant(instant, iChronology); adjustForMinMax(); }
/** * Get this object as a DateTime, returning <code>this</code> if possible. * * @param chronology chronology to apply, or ISOChronology if null * @return a DateTime using the same millis */ public DateTime toDateTime(Chronology chronology) { chronology = DateTimeUtils.getChronology(chronology); if (getChronology() == chronology) { return this; } return super.toDateTime(chronology); }
/** * Sets the chronology of the datetime. * <p> * All changes to the chronology field occurs via this method. * Override and block this method to make a subclass immutable. * * @param chronology the chronology to set */ protected void setChronology(Chronology chronology) { iChronology = checkChronology(chronology); }
/** * Set the chronology of the datetime. * <p> * All changes to the chronology occur via this method. * * @param chronology the chronology to use, null means ISOChronology in default zone */ public void setChronology(Chronology chronology) { super.setChronology(chronology); }
/** * Sets the milliseconds of the datetime. * <p> * All changes to the millisecond field occurs via this method. * Override and block this method to make a subclass immutable. * * @param instant the milliseconds since 1970-01-01T00:00:00Z to set the datetime to */ protected void setMillis(long instant) { iMillis = checkInstant(instant, iChronology); }
/** * Get this object as a DateTime using ISOChronology in the default zone, * returning <code>this</code> if possible. * * @return a DateTime using the same millis */ public DateTime toDateTimeISO() { if (getChronology() == ISOChronology.getInstance()) { return this; } return super.toDateTimeISO(); }