/** * Gets the zone using a fixed offset amount. * * @param id the zone id * @param offset the offset in millis * @return the zone */ private static DateTimeZone fixedOffsetZone(String id, int offset) { if (offset == 0) { return DateTimeZone.UTC; } return new FixedDateTimeZone(id, null, offset, offset); }
public CollectionTypeGetter() { this(FixedDateTimeZone.getDefault()); } public CollectionTypeGetter(DateTimeZone tz) {
/** * Gets the zone using a fixed offset amount. * * @param id the zone id * @param offset the offset in millis * @return the zone */ private static DateTimeZone fixedOffsetZone(String id, int offset) { if (offset == 0) { return DateTimeZone.UTC; } return new FixedDateTimeZone(id, null, offset, offset); }
private static DateTimeZone buildFixedZone(String id, String nameKey, int wallOffset, int standardOffset) { if ("UTC".equals(id) && id.equals(nameKey) && wallOffset == 0 && standardOffset == 0) { return DateTimeZone.UTC; } return new FixedDateTimeZone(id, nameKey, wallOffset, standardOffset); }
public int hashCode() { return getID().hashCode() + 37 * iStandardOffset + 31 * iWallOffset; }
private static DateTimeZone buildFixedZone(String id, String nameKey, int wallOffset, int standardOffset) { if ("UTC".equals(id) && id.equals(nameKey) && wallOffset == 0 && standardOffset == 0) { return DateTimeZone.UTC; } return new FixedDateTimeZone(id, nameKey, wallOffset, standardOffset); }
public int hashCode() { return getID().hashCode() + 37 * iStandardOffset + 31 * iWallOffset; }
/** * Decodes a built DateTimeZone from the given stream, as encoded by * writeTo. * * @param in input stream to read encoded DateTimeZone from. * @param id time zone id to assign */ public static DateTimeZone readFrom(DataInput in, String id) throws IOException { switch (in.readUnsignedByte()) { case 'F': DateTimeZone fixed = new FixedDateTimeZone (id, in.readUTF(), (int)readMillis(in), (int)readMillis(in)); if (fixed.equals(DateTimeZone.UTC)) { fixed = DateTimeZone.UTC; } return fixed; case 'C': return CachedDateTimeZone.forZone(PrecalculatedZone.readFrom(in, id)); case 'P': return PrecalculatedZone.readFrom(in, id); default: throw new IOException("Invalid encoding"); } }
/** * Override to return the correct timezone instance. * @since 1.5 */ public java.util.TimeZone toTimeZone() { String id = getID(); if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) { // standard format offset [+-]hh:mm // our ID is without any prefix, so we need to add the GMT back return java.util.TimeZone.getTimeZone("GMT" + getID()); } // unusual offset, so setup a SimpleTimeZone as best we can return new java.util.SimpleTimeZone(iWallOffset, getID()); }
/** * Decodes a built DateTimeZone from the given stream, as encoded by * writeTo. * * @param in input stream to read encoded DateTimeZone from. * @param id time zone id to assign */ public static DateTimeZone readFrom(DataInput in, String id) throws IOException { switch (in.readUnsignedByte()) { case 'F': DateTimeZone fixed = new FixedDateTimeZone (id, in.readUTF(), (int)readMillis(in), (int)readMillis(in)); if (fixed.equals(DateTimeZone.UTC)) { fixed = DateTimeZone.UTC; } return fixed; case 'C': return CachedDateTimeZone.forZone(PrecalculatedZone.readFrom(in, id)); case 'P': return PrecalculatedZone.readFrom(in, id); default: throw new IOException("Invalid encoding"); } }
/** * Override to return the correct timezone instance. * @since 1.5 */ public java.util.TimeZone toTimeZone() { String id = getID(); if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) { // standard format offset [+-]hh:mm // our ID is without any prefix, so we need to add the GMT back return java.util.TimeZone.getTimeZone("GMT" + getID()); } // unusual offset, so setup a SimpleTimeZone as best we can return new java.util.SimpleTimeZone(iWallOffset, getID()); }
private static DateTimeZone buildFixedZone(String id, String nameKey, int wallOffset, int standardOffset) { if ("UTC".equals(id) && id.equals(nameKey) && wallOffset == 0 && standardOffset == 0) { return DateTimeZone.UTC; } return new FixedDateTimeZone(id, nameKey, wallOffset, standardOffset); }
/** * Gets the zone using a fixed offset amount. * * @param id the zone id * @param offset the offset in millis * @return the zone */ private static synchronized DateTimeZone fixedOffsetZone(String id, int offset) { if (offset == 0) { return DateTimeZone.UTC; } if (iFixedOffsetCache == null) { iFixedOffsetCache = new HashMap<String, SoftReference<DateTimeZone>>(); } DateTimeZone zone; Reference<DateTimeZone> ref = iFixedOffsetCache.get(id); if (ref != null) { zone = ref.get(); if (zone != null) { return zone; } } zone = new FixedDateTimeZone(id, null, offset, offset); iFixedOffsetCache.put(id, new SoftReference<DateTimeZone>(zone)); return zone; }
public int hashCode() { return getID().hashCode() + 37 * iStandardOffset + 31 * iWallOffset; }
/** * Decodes a built DateTimeZone from the given stream, as encoded by * writeTo. * * @param in input stream to read encoded DateTimeZone from. * @param id time zone id to assign */ public static DateTimeZone readFrom(DataInput in, String id) throws IOException { switch (in.readUnsignedByte()) { case 'F': DateTimeZone fixed = new FixedDateTimeZone (id, in.readUTF(), (int)readMillis(in), (int)readMillis(in)); if (fixed.equals(DateTimeZone.UTC)) { fixed = DateTimeZone.UTC; } return fixed; case 'C': return CachedDateTimeZone.forZone(PrecalculatedZone.readFrom(in, id)); case 'P': return PrecalculatedZone.readFrom(in, id); default: throw new IOException("Invalid encoding"); } }
/** * Override to return the correct timzone instance. * @since 1.5 */ public java.util.TimeZone toTimeZone() { String id = getID(); if (id.length() == 6 && (id.startsWith("+") || id.startsWith("-"))) { // standard format offset [+-]hh:mm // our ID is without any prefix, so we need to add the GMT back return java.util.TimeZone.getTimeZone("GMT" + getID()); } // unusual offset, so setup a SimpleTimeZone as best we can return new java.util.SimpleTimeZone(iWallOffset, getID()); }
public static final DateTimeZone UTC = new FixedDateTimeZone("UTC", "UTC", 0, 0);