Java Code Examples for org.joda.time.Chronology#getZone()

The following examples show how to use org.joda.time.Chronology#getZone() . 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: DateTimeFormatter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 2
Source File: Cardumen_0073_s.java    From coming with MIT License 6 votes vote down vote up
private void printTo(StringBuffer buf, long instant, Chronology chrono) {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 3
Source File: Cardumen_0073_t.java    From coming with MIT License 6 votes vote down vote up
private void printTo(StringBuffer buf, long instant, Chronology chrono) {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 4
Source File: Cardumen_0073_t.java    From coming with MIT License 6 votes vote down vote up
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 5
Source File: DateTimeFormatter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 6
Source File: Time_16_DateTimeFormatter_s.java    From coming with MIT License 6 votes vote down vote up
private void printTo(Writer buf, long instant, Chronology chrono) throws IOException {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 7
Source File: Time_7_DateTimeFormatter_t.java    From coming with MIT License 6 votes vote down vote up
private void printTo(StringBuffer buf, long instant, Chronology chrono) {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 8
Source File: DateTimeFormatter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void printTo(StringBuffer buf, long instant, Chronology chrono) {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 9
Source File: DateTimeFormatter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void printTo(StringBuffer buf, long instant, Chronology chrono) {
    DateTimePrinter printer = requirePrinter();
    chrono = selectChronology(chrono);
    // Shift instant into local time (UTC) to avoid excessive offset
    // calculations when printing multiple fields in a composite printer.
    DateTimeZone zone = chrono.getZone();
    int offset = zone.getOffset(instant);
    long adjustedInstant = instant + offset;
    if ((instant ^ adjustedInstant) < 0 && (instant ^ offset) >= 0) {
        // Time zone offset overflow, so revert to UTC.
        zone = DateTimeZone.UTC;
        offset = 0;
        adjustedInstant = instant;
    }
    printer.printTo(buf, adjustedInstant, chrono.withUTC(), offset, zone, iLocale);
}
 
Example 10
Source File: Time_6_GJChronology_s.java    From coming with MIT License 5 votes vote down vote up
public DateTimeZone getZone() {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getZone();
    }
    return DateTimeZone.UTC;
}
 
Example 11
Source File: 1_BasicChronology.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
public DateTimeZone getZone() {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getZone();
    }
    return DateTimeZone.UTC;
}
 
Example 12
Source File: ReadableInstantConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the chronology, which is taken from the ReadableInstant.
 * If the chronology on the instant is null, the ISOChronology in the
 * specified time zone is used.
 * If the chronology on the instant is not in the specified zone, it is
 * adapted.
 * 
 * @param object  the ReadableInstant 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) {
    Chronology chrono = ((ReadableInstant) object).getChronology();
    if (chrono == null) {
        return ISOChronology.getInstance(zone);
    }
    DateTimeZone chronoZone = chrono.getZone();
    if (chronoZone != zone) {
        chrono = chrono.withZone(zone);
        if (chrono == null) {
            return ISOChronology.getInstance(zone);
        }
    }
    return chrono;
}
 
Example 13
Source File: ReadableInstantConverter.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets the chronology, which is taken from the ReadableInstant.
 * If the chronology on the instant is null, the ISOChronology in the
 * specified time zone is used.
 * If the chronology on the instant is not in the specified zone, it is
 * adapted.
 * 
 * @param object  the ReadableInstant 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) {
    Chronology chrono = ((ReadableInstant) object).getChronology();
    if (chrono == null) {
        return ISOChronology.getInstance(zone);
    }
    DateTimeZone chronoZone = chrono.getZone();
    if (chronoZone != zone) {
        chrono = chrono.withZone(zone);
        if (chrono == null) {
            return ISOChronology.getInstance(zone);
        }
    }
    return chrono;
}
 
Example 14
Source File: Time_18_GJChronology_t.java    From coming with MIT License 5 votes vote down vote up
public DateTimeZone getZone() {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getZone();
    }
    return DateTimeZone.UTC;
}
 
Example 15
Source File: Nopol2017_0087_s.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs a bucket, with the option of specifying the pivot year for
 * two-digit year parsing.
 *
 * @param instantLocal  the initial millis from 1970-01-01T00:00:00, local time
 * @param chrono  the chronology to use
 * @param locale  the locale to use
 * @param pivotYear  the pivot year to use when parsing two-digit years
 * @since 2.0
 */
public DateTimeParserBucket(long instantLocal, Chronology chrono,
        Locale locale, Integer pivotYear, int defaultYear) {
    super();
    chrono = DateTimeUtils.getChronology(chrono);
    iMillis = instantLocal;
    iZone = chrono.getZone();
    iChrono = chrono.withUTC();
    iLocale = (locale == null ? Locale.getDefault() : locale);
    iPivotYear = pivotYear;
    iDefaultYear = defaultYear;
}
 
Example 16
Source File: Nopol2017_0087_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs a bucket, with the option of specifying the pivot year for
 * two-digit year parsing.
 *
 * @param instantLocal  the initial millis from 1970-01-01T00:00:00, local time
 * @param chrono  the chronology to use
 * @param locale  the locale to use
 * @param pivotYear  the pivot year to use when parsing two-digit years
 * @since 2.0
 */
public DateTimeParserBucket(long instantLocal, Chronology chrono,
        Locale locale, Integer pivotYear, int defaultYear) {
    super();
    chrono = DateTimeUtils.getChronology(chrono);
    iMillis = instantLocal;
    iZone = chrono.getZone();
    iChrono = chrono.withUTC();
    iLocale = (locale == null ? Locale.getDefault() : locale);
    iPivotYear = pivotYear;
    iDefaultYear = defaultYear;
}
 
Example 17
Source File: DateTimeParserBucket.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a bucket, with the option of specifying the pivot year for
 * two-digit year parsing.
 *
 * @param instantLocal  the initial millis from 1970-01-01T00:00:00, local time
 * @param chrono  the chronology to use
 * @param locale  the locale to use
 * @param pivotYear  the pivot year to use when parsing two-digit years
 * @since 2.0
 */
public DateTimeParserBucket(long instantLocal, Chronology chrono,
        Locale locale, Integer pivotYear, int defaultYear) {
    super();
    chrono = DateTimeUtils.getChronology(chrono);
    iMillis = instantLocal;
    iZone = chrono.getZone();
    iChrono = chrono.withUTC();
    iLocale = (locale == null ? Locale.getDefault() : locale);
    iPivotYear = pivotYear;
    iDefaultYear = defaultYear;
}
 
Example 18
Source File: Nopol2017_0091_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Constructs a bucket, with the option of specifying the pivot year for
 * two-digit year parsing.
 *
 * @param instantLocal  the initial millis from 1970-01-01T00:00:00, local time
 * @param chrono  the chronology to use
 * @param locale  the locale to use
 * @param pivotYear  the pivot year to use when parsing two-digit years
 * @since 2.0
 */
public DateTimeParserBucket(long instantLocal, Chronology chrono,
        Locale locale, Integer pivotYear, int defaultYear) {
    super();
    chrono = DateTimeUtils.getChronology(chrono);
    iMillis = instantLocal;
    iZone = chrono.getZone();
    iChrono = chrono.withUTC();
    iLocale = (locale == null ? Locale.getDefault() : locale);
    iPivotYear = pivotYear;
    iDefaultYear = defaultYear;
}
 
Example 19
Source File: AssembledChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public DateTimeZone getZone() {
    Chronology base;
    if ((base = iBase) != null) {
        return base.getZone();
    }
    return null;
}
 
Example 20
Source File: BasicChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public DateTimeZone getZone() {
    Chronology base;
    if ((base = getBase()) != null) {
        return base.getZone();
    }
    return DateTimeZone.UTC;
}