private TimeZone makeTimeZone(String id, boolean clone) throws IOException { // Check the aliases first String realId = deprecatedAliases.get(id); if (realId != null) { return makeTimeZone(realId, clone); } // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } ZoneInfo zoneInfo = zoneInfos[index]; if (zoneInfo != null) { return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; } byte[] bytes = IoUtils.readFileAsByteArray(ZONE_DIRECTORY_NAME + id); BufferIterator it = HeapBufferIterator.iterator(bytes, 0, bytes.length, ByteOrder.BIG_ENDIAN); zoneInfo = (ZoneInfo) ZoneInfo.makeTimeZone(id, it); zoneInfos[index] = zoneInfo; return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; }
@Override public boolean equals(Object obj) { if (!(obj instanceof ZoneInfo)) { return false; } ZoneInfo other = (ZoneInfo) obj; return getID().equals(other.getID()) && hasSameRules(other); }
@Override public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis) { // XXX This assumes Gregorian always; Calendar switches from // Julian to Gregorian in 1582. What calendar system are the // arguments supposed to come from? long calc = (year / 400) * MILLISECONDS_PER_400_YEARS; year %= 400; calc += year * (365 * MILLISECONDS_PER_DAY); calc += ((year + 3) / 4) * MILLISECONDS_PER_DAY; if (year > 0) { calc -= ((year - 1) / 100) * MILLISECONDS_PER_DAY; } boolean isLeap = (year == 0 || (year % 4 == 0 && year % 100 != 0)); int[] mlen = isLeap ? LEAP : NORMAL; calc += mlen[month] * MILLISECONDS_PER_DAY; calc += (day - 1) * MILLISECONDS_PER_DAY; calc += millis; calc -= mRawOffset; calc -= UNIX_OFFSET; return getOffset(calc); }
@Override public String toString() { return getClass().getName() + "[id=\"" + getID() + "\"" + ",mRawOffset=" + mRawOffset + ",mEarliestRawOffset=" + mEarliestRawOffset + ",mUseDst=" + mUseDst + ",mDstSavings=" + mDstSavings + ",transitions=" + mTransitions.length + "]"; } }
public TimeZone makeTimeZone(String id) throws IOException { // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } BufferIterator it = mappedFile.bigEndianIterator(); it.skip(byteOffsets[index]); return ZoneInfo.makeTimeZone(id, it); } }
return new ZoneInfo(id, transitions, type, gmtOffsets, isDsts);
mTypes = types; mIsDsts = isDsts; setID(name);
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + getID().hashCode(); result = prime * result + Arrays.hashCode(mOffsets); result = prime * result + Arrays.hashCode(mIsDsts); result = prime * result + mRawOffset; result = prime * result + Arrays.hashCode(mTransitions); result = prime * result + Arrays.hashCode(mTypes); result = prime * result + (mUseDst ? 1231 : 1237); return result; }
public TimeZone makeTimeZone(String id) throws IOException { // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } BufferIterator it = mappedFile.bigEndianIterator(); it.skip(byteOffsets[index]); return ZoneInfo.makeTimeZone(id, it); } }
return new ZoneInfo(id, transitions, type, gmtOffsets, isDsts);
mTypes = types; mIsDsts = isDsts; setID(name);
@Override public boolean equals(Object obj) { if (!(obj instanceof ZoneInfo)) { return false; } ZoneInfo other = (ZoneInfo) obj; return getID().equals(other.getID()) && hasSameRules(other); }
private TimeZone makeTimeZone(String id, boolean clone) throws IOException { // Check the aliases first String realId = deprecatedAliases.get(id); if (realId != null) { return makeTimeZone(realId, clone); } // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } ZoneInfo zoneInfo = zoneInfos[index]; if (zoneInfo != null) { return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; } byte[] bytes = IoUtils.readFileAsByteArray(ZONE_DIRECTORY_NAME + id); BufferIterator it = HeapBufferIterator.iterator(bytes, 0, bytes.length, ByteOrder.BIG_ENDIAN); zoneInfo = (ZoneInfo) ZoneInfo.makeTimeZone(id, it); zoneInfos[index] = zoneInfo; return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; }
@Override public String toString() { return getClass().getName() + "[id=\"" + getID() + "\"" + ",mRawOffset=" + mRawOffset + ",mEarliestRawOffset=" + mEarliestRawOffset + ",mUseDst=" + mUseDst + ",mDstSavings=" + mDstSavings + ",transitions=" + mTransitions.length + "]"; } }
public TimeZone makeTimeZone(String id) throws IOException { // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } BufferIterator it = mappedFile.bigEndianIterator(); it.skip(byteOffsets[index]); return ZoneInfo.makeTimeZone(id, it); } }
@Override public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis) { // XXX This assumes Gregorian always; Calendar switches from // Julian to Gregorian in 1582. What calendar system are the // arguments supposed to come from? long calc = (year / 400) * MILLISECONDS_PER_400_YEARS; year %= 400; calc += year * (365 * MILLISECONDS_PER_DAY); calc += ((year + 3) / 4) * MILLISECONDS_PER_DAY; if (year > 0) { calc -= ((year - 1) / 100) * MILLISECONDS_PER_DAY; } boolean isLeap = (year == 0 || (year % 4 == 0 && year % 100 != 0)); int[] mlen = isLeap ? LEAP : NORMAL; calc += mlen[month] * MILLISECONDS_PER_DAY; calc += (day - 1) * MILLISECONDS_PER_DAY; calc += millis; calc -= mRawOffset; calc -= UNIX_OFFSET; return getOffset(calc); }
return new ZoneInfo(id, transitions, type, gmtOffsets, isDsts);
mTypes = types; mIsDsts = isDsts; setID(name);
@Override public boolean equals(Object obj) { if (!(obj instanceof ZoneInfo)) { return false; } ZoneInfo other = (ZoneInfo) obj; return getID().equals(other.getID()) && hasSameRules(other); }
private TimeZone makeTimeZone(String id, boolean clone) throws IOException { // Check the aliases first String realId = deprecatedAliases.get(id); if (realId != null) { return makeTimeZone(realId, clone); } // Work out where in the big data file this time zone is. int index = Arrays.binarySearch(ids, id); if (index < 0) { return null; } ZoneInfo zoneInfo = zoneInfos[index]; if (zoneInfo != null) { return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; } byte[] bytes = IoUtils.readFileAsByteArray(ZONE_DIRECTORY_NAME + id); BufferIterator it = HeapBufferIterator.iterator(bytes, 0, bytes.length, ByteOrder.BIG_ENDIAN); zoneInfo = (ZoneInfo) ZoneInfo.makeTimeZone(id, it); zoneInfos[index] = zoneInfo; return clone ? (TimeZone) zoneInfo.clone() : zoneInfo; }