Java Code Examples for org.joda.time.DateTimeUtils#getInstantChronology()
The following examples show how to use
org.joda.time.DateTimeUtils#getInstantChronology() .
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 start point and duration. * * @param startInstant the interval start, null means now * @param duration the duration of the interval, null means zero-length * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) { super(); type = checkPeriodType(type); long startMillis = DateTimeUtils.getInstantMillis(startInstant); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = FieldUtils.safeAdd(startMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); 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 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 3
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 4
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 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 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 6
Source File: Time_22_BasePeriod_s.java From coming with MIT License | 5 votes |
/** * Creates a period from the given duration and end point. * * @param duration the duration of the interval, null means zero-length * @param endInstant the interval end, null means now * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = DateTimeUtils.getInstantMillis(endInstant); long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); }
Example 7
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 8
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 9
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 10
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 11
Source File: BasePeriod.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a period from the given duration and end point. * * @param duration the duration of the interval, null means zero-length * @param endInstant the interval end, null means now * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = DateTimeUtils.getInstantMillis(endInstant); long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); }
Example 12
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 13
Source File: Time_22_BasePeriod_t.java From coming with MIT License | 3 votes |
/** * Gets the total millisecond duration of this period relative to an * end instant. * <p> * This method subtracts the period from 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 endInstant the instant to subtract the period from, thus obtaining the duration * @return the total length of the period as a duration relative to the end instant * @throws ArithmeticException if the millis exceeds the capacity of the duration */ public Duration toDurationTo(ReadableInstant endInstant) { long endMillis = DateTimeUtils.getInstantMillis(endInstant); Chronology chrono = DateTimeUtils.getInstantChronology(endInstant); long startMillis = chrono.add(this, endMillis, -1); return new Duration(startMillis, endMillis); }
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 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 15
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 16
Source File: Cardumen_0073_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 17
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 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 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: Cardumen_0073_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 20
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); }