/** * Gets the chronology, which is taken from the ReadablePartial. * * @param object the ReadablePartial to convert, must not be null * @param zone the specified zone to use, null means default zone * @return the chronology, never null */ public Chronology getChronology(Object object, DateTimeZone zone) { return getChronology(object, (Chronology) null).withZone(zone); }
/** * Gets the chronology, which is taken from the ReadablePartial. * * @param object the ReadablePartial to convert, must not be null * @param zone the specified zone to use, null means default zone * @return the chronology, never null */ public Chronology getChronology(Object object, DateTimeZone zone) { return getChronology(object, (Chronology) null).withZone(zone); }
/** * Determines the correct chronology to use. * * @param chrono the proposed chronology * @return the actual chronology */ private Chronology selectChronology(Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono); if (iChrono != null) { chrono = iChrono; } if (iZone != null) { chrono = chrono.withZone(iZone); } return chrono; }
/** * Determines the correct chronology to use. * * @param chrono the proposed chronology * @return the actual chronology */ private Chronology selectChronology(Chronology chrono) { chrono = DateTimeUtils.getChronology(chrono); if (iChrono != null) { chrono = iChrono; } if (iZone != null) { chrono = chrono.withZone(iZone); } return chrono; }
/** * Get this object as a DateTime using the same chronology but a different zone. * * @param zone time zone to apply, or default if null * @return a DateTime using the same millis */ public DateTime toDateTime(DateTimeZone zone) { Chronology chrono = DateTimeUtils.getChronology(getChronology()); chrono = chrono.withZone(zone); return new DateTime(getMillis(), chrono); }
/** * Get this object as a DateTime using the same chronology but a different zone. * * @param zone time zone to apply, or default if null * @return a DateTime using the same millis */ public DateTime toDateTime(DateTimeZone zone) { Chronology chrono = DateTimeUtils.getChronology(getChronology()); chrono = chrono.withZone(zone); return new DateTime(getMillis(), chrono); }
/** * Converts this partial to a full datetime using the specified time zone * setting the time fields from this instance and the date fields from * the current time. * <p> * This method uses the chronology from this instance plus the time zone * specified. * * @param zone the zone to use, null means default * @return this date as a datetime with the time as the current time */ public DateTime toDateTimeToday(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); long instantMillis = DateTimeUtils.currentTimeMillis(); long resolved = chrono.set(this, instantMillis); return new DateTime(resolved, chrono); }
/** * Converts this LocalTime to a full datetime using the specified time zone * setting the time fields from this instance and the date fields from * the current time. * <p> * This method uses the chronology from this instance plus the time zone * specified. * * @param zone the zone to use, null means default * @return this time as a datetime using today's date */ public DateTime toDateTimeToday(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); long instantMillis = DateTimeUtils.currentTimeMillis(); long resolved = chrono.set(this, instantMillis); return new DateTime(resolved, chrono); }
/** * Converts this partial to a full datetime using the specified time zone * setting the date fields from this instance and the time fields from * the current time. * <p> * This method uses the chronology from this instance plus the time zone * specified. * * @param zone the zone to use, null means default * @return this date as a datetime with the time as the current time */ public DateTime toDateTimeAtCurrentTime(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); long instantMillis = DateTimeUtils.currentTimeMillis(); long resolved = chrono.set(this, instantMillis); return new DateTime(resolved, chrono); }
/** * Converts this YearMonthDay to a full datetime at midnight using the * specified time zone. * <p> * This method uses the chronology from this instance plus the time zone * specified. * * @param zone the zone to use, null means default * @return this date as a datetime at midnight */ public DateTime toDateTimeAtMidnight(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono); }
/** * Converts this YearMonthDay to a full datetime at midnight using the * specified time zone. * <p> * This method uses the chronology from this instance plus the time zone * specified. * * @param zone the zone to use, null means default * @return this date as a datetime at midnight */ public DateTime toDateTimeAtMidnight(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono); }
/** * Get this object as a MutableDateTime using the same chronology but a different zone. * * @param zone time zone to apply, or default if null * @return a MutableDateTime using the same millis */ public MutableDateTime toMutableDateTime(DateTimeZone zone) { Chronology chrono = DateTimeUtils.getChronology(getChronology()); chrono = chrono.withZone(zone); return new MutableDateTime(getMillis(), chrono); }
/** * Get this object as a MutableDateTime using the same chronology but a different zone. * * @param zone time zone to apply, or default if null * @return a MutableDateTime using the same millis */ public MutableDateTime toMutableDateTime(DateTimeZone zone) { Chronology chrono = DateTimeUtils.getChronology(getChronology()); chrono = chrono.withZone(zone); return new MutableDateTime(getMillis(), chrono); }
public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == DateTimeZone.UTC) { return withUTC(); } if (zone == getZone()) { return this; } return StrictChronology.getInstance(getBase().withZone(zone)); }
public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == DateTimeZone.UTC) { return withUTC(); } if (zone == getZone()) { return this; } return LenientChronology.getInstance(getBase().withZone(zone)); }
/** * Converts this object to a DateMidnight. * * @param zone the zone to get the DateMidnight in, null means default * @return the DateMidnight instance */ public DateMidnight toDateMidnight(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono); }
public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == DateTimeZone.UTC) { return withUTC(); } if (zone == getZone()) { return this; } return StrictChronology.getInstance(getBase().withZone(zone)); }
/** * Converts this object to a DateMidnight. * * @param zone the zone to get the DateMidnight in, null means default * @return the DateMidnight instance */ public DateMidnight toDateMidnight(DateTimeZone zone) { Chronology chrono = getChronology().withZone(zone); return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono); }
public Chronology withZone(DateTimeZone zone) { if (zone == null) { zone = DateTimeZone.getDefault(); } if (zone == DateTimeZone.UTC) { return withUTC(); } if (zone == getZone()) { return this; } return LenientChronology.getInstance(getBase().withZone(zone)); }
/** * Returns a copy of this date with a different time zone, preserving the day * The returned object will have a local time of midnight in the new zone on * the same day as the original instant. * * @param newZone the new time zone, null means default * @return a copy of this instant with a different time zone */ public DateMidnight withZoneRetainFields(DateTimeZone newZone) { newZone = DateTimeUtils.getZone(newZone); DateTimeZone originalZone = DateTimeUtils.getZone(getZone()); if (newZone == originalZone) { return this; } long millis = originalZone.getMillisKeepLocal(newZone, getMillis()); return new DateMidnight(millis, getChronology().withZone(newZone)); }