/** * Returns a new CachedDateTimeZone unless given zone is already cached. */ public static CachedDateTimeZone forZone(DateTimeZone zone) { if (zone instanceof CachedDateTimeZone) { return (CachedDateTimeZone)zone; } return new CachedDateTimeZone(zone); }
private Info getInfo(long millis) { int period = (int)(millis >> 32); Info[] cache = iInfoCache; int index = period & cInfoCacheMask; Info info = cache[index]; if (info == null || (int)((info.iPeriodStart >> 32)) != period) { info = createInfo(millis); cache[index] = info; } return info; }
/** * 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"); } }
public String getNameKey(long instant) { return getInfo(instant).getNameKey(instant); }
/** * Encodes a built DateTimeZone to the given stream. Call readFrom to * decode the data into a DateTimeZone object. * * @param out the output stream to receive the encoded DateTimeZone * @since 1.5 (parameter added) */ public void writeTo(String zoneID, DataOutput out) throws IOException { // pass false so zone id is not written out DateTimeZone zone = toDateTimeZone(zoneID, false); if (zone instanceof FixedDateTimeZone) { out.writeByte('F'); // 'F' for fixed out.writeUTF(zone.getNameKey(0)); writeMillis(out, zone.getOffset(0)); writeMillis(out, zone.getStandardOffset(0)); } else { if (zone instanceof CachedDateTimeZone) { out.writeByte('C'); // 'C' for cached, precalculated zone = ((CachedDateTimeZone)zone).getUncachedZone(); } else { out.writeByte('P'); // 'P' for precalculated, uncached } ((PrecalculatedZone)zone).writeTo(out); } }
public int getOffset(long instant) { return getInfo(instant).getOffset(instant); }
/** * Encodes a built DateTimeZone to the given stream. Call readFrom to * decode the data into a DateTimeZone object. * * @param out the output stream to receive the encoded DateTimeZone * @since 1.5 (parameter added) */ public void writeTo(String zoneID, DataOutput out) throws IOException { // pass false so zone id is not written out DateTimeZone zone = toDateTimeZone(zoneID, false); if (zone instanceof FixedDateTimeZone) { out.writeByte('F'); // 'F' for fixed out.writeUTF(zone.getNameKey(0)); writeMillis(out, zone.getOffset(0)); writeMillis(out, zone.getStandardOffset(0)); } else { if (zone instanceof CachedDateTimeZone) { out.writeByte('C'); // 'C' for cached, precalculated zone = ((CachedDateTimeZone)zone).getUncachedZone(); } else { out.writeByte('P'); // 'P' for precalculated, uncached } ((PrecalculatedZone)zone).writeTo(out); } }
public int getStandardOffset(long instant) { return getInfo(instant).getStandardOffset(instant); }
/** * 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"); } }
/** * Returns a new CachedDateTimeZone unless given zone is already cached. */ public static CachedDateTimeZone forZone(DateTimeZone zone) { if (zone instanceof CachedDateTimeZone) { return (CachedDateTimeZone)zone; } return new CachedDateTimeZone(zone); }
private Info getInfo(long millis) { int period = (int)(millis >> 32); Info[] cache = iInfoCache; int index = period & cInfoCacheMask; Info info = cache[index]; if (info == null || (int)((info.iPeriodStart >> 32)) != period) { info = createInfo(millis); cache[index] = info; } return info; }
/** * Encodes a built DateTimeZone to the given stream. Call readFrom to * decode the data into a DateTimeZone object. * * @param out the output stream to receive the encoded DateTimeZone * @since 1.5 (parameter added) */ public void writeTo(String zoneID, DataOutput out) throws IOException { // pass false so zone id is not written out DateTimeZone zone = toDateTimeZone(zoneID, false); if (zone instanceof FixedDateTimeZone) { out.writeByte('F'); // 'F' for fixed out.writeUTF(zone.getNameKey(0)); writeMillis(out, zone.getOffset(0)); writeMillis(out, zone.getStandardOffset(0)); } else { if (zone instanceof CachedDateTimeZone) { out.writeByte('C'); // 'C' for cached, precalculated zone = ((CachedDateTimeZone)zone).getUncachedZone(); } else { out.writeByte('P'); // 'P' for precalculated, uncached } ((PrecalculatedZone)zone).writeTo(out); } }
public int getOffset(long instant) { return getInfo(instant).getOffset(instant); }
return CachedDateTimeZone.forZone(zone);
/** * Returns a new CachedDateTimeZone unless given zone is already cached. */ public static CachedDateTimeZone forZone(DateTimeZone zone) { if (zone instanceof CachedDateTimeZone) { return (CachedDateTimeZone)zone; } return new CachedDateTimeZone(zone); }
private Info getInfo(long millis) { int period = (int)(millis >> 32); Info[] cache = iInfoCache; int index = period & cInfoCacheMask; Info info = cache[index]; if (info == null || (int)((info.iPeriodStart >> 32)) != period) { info = createInfo(millis); cache[index] = info; } return info; }
/** * Encodes a built DateTimeZone to the given stream. Call readFrom to * decode the data into a DateTimeZone object. * * @param out the output stream to receive the encoded DateTimeZone * @since 1.5 (parameter added) */ public void writeTo(String zoneID, DataOutput out) throws IOException { // pass false so zone id is not written out DateTimeZone zone = toDateTimeZone(zoneID, false); if (zone instanceof FixedDateTimeZone) { out.writeByte('F'); // 'F' for fixed out.writeUTF(zone.getNameKey(0)); writeMillis(out, zone.getOffset(0)); writeMillis(out, zone.getStandardOffset(0)); } else { if (zone instanceof CachedDateTimeZone) { out.writeByte('C'); // 'C' for cached, precalculated zone = ((CachedDateTimeZone)zone).getUncachedZone(); } else { out.writeByte('P'); // 'P' for precalculated, uncached } ((PrecalculatedZone)zone).writeTo(out); } }
public int getStandardOffset(long instant) { return getInfo(instant).getStandardOffset(instant); }
return CachedDateTimeZone.forZone(zone);
/** * Returns a new CachedDateTimeZone unless given zone is already cached. */ public static CachedDateTimeZone forZone(DateTimeZone zone) { if (zone instanceof CachedDateTimeZone) { return (CachedDateTimeZone)zone; } return new CachedDateTimeZone(zone); }