/** * Gets the time zone of the instant from the chronology. * * @return the DateTimeZone that the instant is using, never null */ public DateTimeZone getZone() { return getChronology().getZone(); }
/** * Gets the time zone of the instant from the chronology. * * @return the DateTimeZone that the instant is using, never null */ public DateTimeZone getZone() { return getChronology().getZone(); }
/** * Gets a hash code for the instant as defined in <code>ReadableInstant</code>. * * @return a suitable hash code */ public int hashCode() { // must be to fulfil ReadableInstant contract return ((int) (getMillis() ^ (getMillis() >>> 32))) + (getChronology().hashCode()); }
/** * Gets a hash code for the instant as defined in <code>ReadableInstant</code>. * * @return a suitable hash code */ public int hashCode() { // must be to fulfil ReadableInstant contract return ((int) (getMillis() ^ (getMillis() >>> 32))) + (getChronology().hashCode()); }
/** * Checks if the field type specified is supported by this instant and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } return type.getField(getChronology()).isSupported(); }
/** * Checks if the field type specified is supported by this instant and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } return type.getField(getChronology()).isSupported(); }
/** * 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); }
/** * Get the value of one of the fields of a datetime using the chronology of the instant. * <p> * This method uses the chronology of the instant to obtain the value. * For example: * <pre> * DateTime dt = new DateTime(); * int year = dt.get(DateTimeFieldType.year()); * </pre> * * @param type a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType type) { if (type == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } return type.getField(getChronology()).get(getMillis()); }
/** * Get the value of one of the fields of a datetime using the chronology of the instant. * <p> * This method uses the chronology of the instant to obtain the value. * For example: * <pre> * DateTime dt = new DateTime(); * int year = dt.get(DateTimeFieldType.year()); * </pre> * * @param type a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType type) { if (type == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } return type.getField(getChronology()).get(getMillis()); }
/** * 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); }
return getMillis() == otherInstant.getMillis() && FieldUtils.equals(getChronology(), otherInstant.getChronology());
return getMillis() == otherInstant.getMillis() && FieldUtils.equals(getChronology(), otherInstant.getChronology());
/** * Gets the time zone of the instant from the chronology. * * @return the DateTimeZone that the instant is using, never null */ public DateTimeZone getZone() { return getChronology().getZone(); }
/** * Gets a hash code for the instant as defined in <code>ReadableInstant</code>. * * @return a suitable hash code */ public int hashCode() { // must be to fulfil ReadableInstant contract return ((int) (getMillis() ^ (getMillis() >>> 32))) + (getChronology().hashCode()); }
/** * Checks if the field type specified is supported by this instant and chronology. * This can be used to avoid exceptions in {@link #get(DateTimeFieldType)}. * * @param type a field type, usually obtained from DateTimeFieldType * @return true if the field type is supported */ public boolean isSupported(DateTimeFieldType type) { if (type == null) { return false; } return type.getField(getChronology()).isSupported(); }
/** * 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 the value of one of the fields of a datetime using the chronology of the instant. * <p> * This method uses the chronology of the instant to obtain the value. * For example: * <pre> * DateTime dt = new DateTime(); * int year = dt.get(DateTimeFieldType.year()); * </pre> * * @param type a field type, usually obtained from DateTimeFieldType, not null * @return the value of that field * @throws IllegalArgumentException if the field type is null */ public int get(DateTimeFieldType type) { if (type == null) { throw new IllegalArgumentException("The DateTimeFieldType must not be null"); } return type.getField(getChronology()).get(getMillis()); }
/** * 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); }