public DurationFieldType getType() { return DurationFieldType.millis(); }
public DurationFieldType getType() { return DurationFieldType.millis(); }
/** * Sets the number of millis of the period. * * @param millis the number of millis * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setMillis(int millis) { super.setField(DurationFieldType.millis(), millis); }
/** * Get the millis duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField millis() { return UnsupportedDurationField.getInstance(DurationFieldType.millis()); }
/** * Adds the specified millis to the number of millis in the period. * * @param millis the number of millis * @throws IllegalArgumentException if field is not supported and the value is non-zero * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void addMillis(int millis) { super.addField(DurationFieldType.millis(), millis); }
/** * Sets the number of millis of the period. * * @param millis the number of millis * @throws IllegalArgumentException if field is not supported and the value is non-zero */ public void setMillis(int millis) { super.setField(DurationFieldType.millis(), millis); }
/** * Adds the specified millis to the number of millis in the period. * * @param millis the number of millis * @throws IllegalArgumentException if field is not supported and the value is non-zero * @throws ArithmeticException if the addition exceeds the capacity of the period */ public void addMillis(int millis) { super.addField(DurationFieldType.millis(), millis); }
/** * Get the millis duration field for this chronology. * * @return DurationField or UnsupportedDurationField if unsupported */ public DurationField millis() { return UnsupportedDurationField.getInstance(DurationFieldType.millis()); }
/** * Gets a type that defines just the millis field. * * @return the period type */ public static PeriodType millis() { PeriodType type = cMillis; if (type == null) { type = new PeriodType( "Millis", new DurationFieldType[] { DurationFieldType.millis() }, new int[] { -1, -1, -1, -1, -1, -1, -1, 0, } ); cMillis = type; } return type; }
/** * Returns a copy of this time plus the specified number of millis. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay added = dt.plusMillis(6); * TimeOfDay added = dt.plus(Period.millis(6)); * TimeOfDay added = dt.withFieldAdded(DurationFieldType.millis(), 6); * </pre> * * @param millis the amount of millis to add, may be negative * @return the new time plus the increased millis * @since 1.1 */ public TimeOfDay plusMillis(int millis) { return withFieldAdded(DurationFieldType.millis(), millis); }
/** * Gets a type that defines just the millis field. * * @return the period type */ public static PeriodType millis() { PeriodType type = cMillis; if (type == null) { type = new PeriodType( "Millis", new DurationFieldType[] { DurationFieldType.millis() }, new int[] { -1, -1, -1, -1, -1, -1, -1, 0, } ); cMillis = type; } return type; }
/** * Returns a copy of this time plus the specified number of millis. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay added = dt.plusMillis(6); * TimeOfDay added = dt.plus(Period.millis(6)); * TimeOfDay added = dt.withFieldAdded(DurationFieldType.millis(), 6); * </pre> * * @param millis the amount of millis to add, may be negative * @return the new time plus the increased millis * @since 1.1 */ public TimeOfDay plusMillis(int millis) { return withFieldAdded(DurationFieldType.millis(), millis); }
/** * Returns a copy of this time minus the specified number of millis. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay subtracted = dt.minusMillis(6); * TimeOfDay subtracted = dt.minus(Period.millis(6)); * TimeOfDay subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6); * </pre> * * @param millis the amount of millis to subtract, may be negative * @return the new time minus the increased millis * @since 1.1 */ public TimeOfDay minusMillis(int millis) { return withFieldAdded(DurationFieldType.millis(), FieldUtils.safeNegate(millis)); }
/** * Returns a copy of this time minus the specified number of millis. * <p> * This time instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * TimeOfDay subtracted = dt.minusMillis(6); * TimeOfDay subtracted = dt.minus(Period.millis(6)); * TimeOfDay subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6); * </pre> * * @param millis the amount of millis to subtract, may be negative * @return the new time minus the increased millis * @since 1.1 */ public TimeOfDay minusMillis(int millis) { return withFieldAdded(DurationFieldType.millis(), FieldUtils.safeNegate(millis)); }
/** * Gets a type that defines all standard time fields. * <ul> * <li>hours * <li>minutes * <li>seconds * <li>milliseconds * </ul> * * @return the period type */ public static PeriodType time() { PeriodType type = cTime; if (type == null) { type = new PeriodType( "Time", new DurationFieldType[] { DurationFieldType.hours(), DurationFieldType.minutes(), DurationFieldType.seconds(), DurationFieldType.millis(), }, new int[] { -1, -1, -1, -1, 0, 1, 2, 3, } ); cTime = type; } return type; }
private static long millisBetween(ReadableInstant start, ReadableInstant end) { requireNonNull(start, "start is null"); requireNonNull(end, "end is null"); return millis().getField(getInstantChronology(start)).getDifferenceAsLong(end.getMillis(), start.getMillis()); }
/** * Gets a type that defines all standard fields from days downwards. * <ul> * <li>days * <li>hours * <li>minutes * <li>seconds * <li>milliseconds * </ul> * * @return the period type */ public static PeriodType dayTime() { PeriodType type = cDTime; if (type == null) { type = new PeriodType( "DayTime", new DurationFieldType[] { DurationFieldType.days(), DurationFieldType.hours(), DurationFieldType.minutes(), DurationFieldType.seconds(), DurationFieldType.millis(), }, new int[] { -1, -1, -1, 0, 1, 2, 3, 4, } ); cDTime = type; } return type; }
boolean isSupported(PeriodType type, int field) { switch (field) { default: return false; case YEARS: return type.isSupported(DurationFieldType.years()); case MONTHS: return type.isSupported(DurationFieldType.months()); case WEEKS: return type.isSupported(DurationFieldType.weeks()); case DAYS: return type.isSupported(DurationFieldType.days()); case HOURS: return type.isSupported(DurationFieldType.hours()); case MINUTES: return type.isSupported(DurationFieldType.minutes()); case SECONDS: return type.isSupported(DurationFieldType.seconds()); case MILLIS: return type.isSupported(DurationFieldType.millis()); case SECONDS_MILLIS: // drop through case SECONDS_OPTIONAL_MILLIS: return type.isSupported(DurationFieldType.seconds()) || type.isSupported(DurationFieldType.millis()); } }
/** * Private method called from constructor. */ private int[] setPeriodInternal(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { int[] newValues = new int[size()]; checkAndUpdate(DurationFieldType.years(), newValues, years); checkAndUpdate(DurationFieldType.months(), newValues, months); checkAndUpdate(DurationFieldType.weeks(), newValues, weeks); checkAndUpdate(DurationFieldType.days(), newValues, days); checkAndUpdate(DurationFieldType.hours(), newValues, hours); checkAndUpdate(DurationFieldType.minutes(), newValues, minutes); checkAndUpdate(DurationFieldType.seconds(), newValues, seconds); checkAndUpdate(DurationFieldType.millis(), newValues, millis); return newValues; }
/** * Private method called from constructor. */ private int[] setPeriodInternal(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis) { int[] newValues = new int[size()]; checkAndUpdate(DurationFieldType.years(), newValues, years); checkAndUpdate(DurationFieldType.months(), newValues, months); checkAndUpdate(DurationFieldType.weeks(), newValues, weeks); checkAndUpdate(DurationFieldType.days(), newValues, days); checkAndUpdate(DurationFieldType.hours(), newValues, hours); checkAndUpdate(DurationFieldType.minutes(), newValues, minutes); checkAndUpdate(DurationFieldType.seconds(), newValues, seconds); checkAndUpdate(DurationFieldType.millis(), newValues, millis); return newValues; }