Java Code Examples for org.joda.time.DateTimeUtils#getInstantMillis()
The following examples show how to use
org.joda.time.DateTimeUtils#getInstantMillis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Time_22_BasePeriod_s.java From coming with MIT License | 5 votes |
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, null means now * @param endInstant interval end, null means now * @param type which set of fields this period supports, null means standard * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); if (startInstant == null && endInstant == null) { iType = type; iValues = new int[size()]; } else { long startMillis = DateTimeUtils.getInstantMillis(startInstant); long endMillis = DateTimeUtils.getInstantMillis(endInstant); Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); } }
Example 2
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Constructs an interval from a start instant and a time period. * <p> * When forming the interval, the chronology from the instant is used * if present, otherwise the chronology of the period is used. * * @param start start of this interval, null means now * @param period the period of this interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ protected BaseInterval(ReadableInstant start, ReadablePeriod period) { super(); Chronology chrono = DateTimeUtils.getInstantChronology(start); iChronology = chrono; iStartMillis = DateTimeUtils.getInstantMillis(start); if (period == null) { iEndMillis = iStartMillis; } else { iEndMillis = chrono.add(period, iStartMillis, 1); } checkInterval(iStartMillis, iEndMillis); }
Example 3
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Constructs an interval from a millisecond duration and an end instant. * * @param duration the duration of this interval, null means zero length * @param end end of this interval, null means now * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ protected BaseInterval(ReadableDuration duration, ReadableInstant end) { super(); iChronology = DateTimeUtils.getInstantChronology(end); iEndMillis = DateTimeUtils.getInstantMillis(end); long durationMillis = DateTimeUtils.getDurationMillis(duration); iStartMillis = FieldUtils.safeAdd(iEndMillis, -durationMillis); checkInterval(iStartMillis, iEndMillis); }
Example 4
Source File: Time_22_BasePeriod_t.java From coming with MIT License | 5 votes |
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, null means now * @param endInstant interval end, null means now * @param type which set of fields this period supports, null means standard * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); if (startInstant == null && endInstant == null) { iType = type; iValues = new int[size()]; } else { long startMillis = DateTimeUtils.getInstantMillis(startInstant); long endMillis = DateTimeUtils.getInstantMillis(endInstant); Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); } }
Example 5
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Constructs an interval from a start instant and a duration. * * @param start start of this interval, null means now * @param duration the duration of this interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ protected BaseInterval(ReadableInstant start, ReadableDuration duration) { super(); iChronology = DateTimeUtils.getInstantChronology(start); iStartMillis = DateTimeUtils.getInstantMillis(start); long durationMillis = DateTimeUtils.getDurationMillis(duration); iEndMillis = FieldUtils.safeAdd(iStartMillis, durationMillis); checkInterval(iStartMillis, iEndMillis); }
Example 6
Source File: BaseDuration.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a duration from the given interval endpoints. * * @param start interval start, null means now * @param end interval end, null means now * @throws ArithmeticException if the duration exceeds a 64 bit long */ protected BaseDuration(ReadableInstant start, ReadableInstant end) { super(); if (start == end) { iMillis = 0L; } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); iMillis = FieldUtils.safeAdd(endMillis, -startMillis); } }
Example 7
Source File: BaseInterval.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Constructs an interval from a time period and an end instant. * <p> * When forming the interval, the chronology from the instant is used * if present, otherwise the chronology of the period is used. * * @param period the period of this interval, null means zero length * @param end end of this interval, null means now * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ protected BaseInterval(ReadablePeriod period, ReadableInstant end) { super(); Chronology chrono = DateTimeUtils.getInstantChronology(end); iChronology = chrono; iEndMillis = DateTimeUtils.getInstantMillis(end); if (period == null) { iStartMillis = iEndMillis; } else { iStartMillis = chrono.add(period, iEndMillis, -1); } checkInterval(iStartMillis, iEndMillis); }
Example 8
Source File: AbstractPartial.java From astor with GNU General Public License v2.0 | 3 votes |
/** * Resolves this partial against another complete instant to create a new * full instant. The combination is performed using the chronology of the * specified instant. * <p> * For example, if this partial represents a time, then the result of this * method will be the datetime from the specified base instant plus the * time from this partial. * * @param baseInstant the instant that provides the missing fields, null means now * @return the combined datetime */ public DateTime toDateTime(ReadableInstant baseInstant) { Chronology chrono = DateTimeUtils.getInstantChronology(baseInstant); long instantMillis = DateTimeUtils.getInstantMillis(baseInstant); long resolved = chrono.set(this, instantMillis); return new DateTime(resolved, chrono); }
Example 9
Source File: Time_22_BasePeriod_s.java From coming with MIT License | 3 votes |
/** * Gets the total millisecond duration of this period relative to a start instant. * <p> * This method adds the period to the specified instant in order to * calculate the duration. * <p> * An instant must be supplied as the duration of a period varies. * For example, a period of 1 month could vary between the equivalent of * 28 and 31 days in milliseconds due to different length months. * Similarly, a day can vary at Daylight Savings cutover, typically between * 23 and 25 hours. * * @param startInstant the instant to add the period to, thus obtaining the duration * @return the total length of the period as a duration relative to the start instant * @throws ArithmeticException if the millis exceeds the capacity of the duration */ public Duration toDurationFrom(ReadableInstant startInstant) { long startMillis = DateTimeUtils.getInstantMillis(startInstant); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); long endMillis = chrono.add(this, startMillis, 1); return new Duration(startMillis, endMillis); }
Example 10
Source File: Time_22_BasePeriod_t.java From coming with MIT License | 3 votes |
/** * Gets the total millisecond duration of this period relative to a start instant. * <p> * This method adds the period to the specified instant in order to * calculate the duration. * <p> * An instant must be supplied as the duration of a period varies. * For example, a period of 1 month could vary between the equivalent of * 28 and 31 days in milliseconds due to different length months. * Similarly, a day can vary at Daylight Savings cutover, typically between * 23 and 25 hours. * * @param startInstant the instant to add the period to, thus obtaining the duration * @return the total length of the period as a duration relative to the start instant * @throws ArithmeticException if the millis exceeds the capacity of the duration */ public Duration toDurationFrom(ReadableInstant startInstant) { long startMillis = DateTimeUtils.getInstantMillis(startInstant); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); long endMillis = chrono.add(this, startMillis, 1); return new Duration(startMillis, endMillis); }
Example 11
Source File: Time_16_DateTimeFormatter_s.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param buf the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(StringBuffer buf, ReadableInstant instant) { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(buf, millis, chrono); }
Example 12
Source File: DateTimeFormatter.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param out the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(Writer out, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(out, millis, chrono); }
Example 13
Source File: Time_7_DateTimeFormatter_s.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param out the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(Writer out, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(out, millis, chrono); }
Example 14
Source File: Time_16_DateTimeFormatter_t.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param out the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(Writer out, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(out, millis, chrono); }
Example 15
Source File: Cardumen_0073_t.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param buf the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(StringBuffer buf, ReadableInstant instant) { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(buf, millis, chrono); }
Example 16
Source File: AbstractInstant.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Is this instant before the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is before the instant passed in */ public boolean isBefore(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isBefore(instantMillis); }
Example 17
Source File: DateTimeFormatter.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param buf the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(StringBuffer buf, ReadableInstant instant) { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(buf, millis, chrono); }
Example 18
Source File: Cardumen_0073_s.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param out the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(Writer out, ReadableInstant instant) throws IOException { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(out, millis, chrono); }
Example 19
Source File: Time_7_DateTimeFormatter_t.java From coming with MIT License | 2 votes |
/** * Prints a ReadableInstant, using the chronology supplied by the instant. * * @param buf the destination to format to, not null * @param instant instant to format, null means now */ public void printTo(StringBuffer buf, ReadableInstant instant) { long millis = DateTimeUtils.getInstantMillis(instant); Chronology chrono = DateTimeUtils.getInstantChronology(instant); printTo(buf, millis, chrono); }
Example 20
Source File: AbstractInstant.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Is this instant after the instant passed in * comparing solely by millisecond. * * @param instant an instant to check against, null means now * @return true if the instant is after the instant passed in */ public boolean isAfter(ReadableInstant instant) { long instantMillis = DateTimeUtils.getInstantMillis(instant); return isAfter(instantMillis); }