public TimeZone makeTimeZone(String id) throws IOException { return makeTimeZone(id, true); }
/** * Traditionally, Unix systems have one file per time zone. We have one big data file, which * is just a concatenation of regular time zone files. To allow random access into this big * data file, we also have an index. We read the index at startup, and keep it in memory so * we can binary search by id when we need time zone data. * * The format of this file is, I believe, Android's own, and undocumented. * * All this code assumes strings are US-ASCII. */ private static void readIndex() { try { readIndexMulti(); } catch (Exception ex) { throw new AssertionError(ex); } zoneInfos = new ZoneInfo[ids.length]; }
public TimeZone makeTimeZone(String id) throws IOException { return makeTimeZone(id, true); }
/** * Traditionally, Unix systems have one file per time zone. We have one big data file, which * is just a concatenation of regular time zone files. To allow random access into this big * data file, we also have an index. We read the index at startup, and keep it in memory so * we can binary search by id when we need time zone data. * * The format of this file is, I believe, Android's own, and undocumented. * * All this code assumes strings are US-ASCII. */ private static void readIndex() { try { readIndexMulti(); } catch (Exception ex) { throw new AssertionError(ex); } zoneInfos = new ZoneInfo[ids.length]; }
public String[] getAvailableIDs(int rawOffset) { List<String> matches = new ArrayList<String>(); // Unfortunately we need load each ZoneInfo to determine the offset for (String id : ids) { try { TimeZone timeZone = makeTimeZone(id, false); if (timeZone.getRawOffset() == rawOffset) { matches.add(id); } } catch (IOException e) { } } return matches.toArray(new String[matches.size()]); }
public String[] getAvailableIDs(int rawOffset) { List<String> matches = new ArrayList<String>(); // Unfortunately we need load each ZoneInfo to determine the offset for (String id : ids) { try { TimeZone timeZone = makeTimeZone(id, false); if (timeZone.getRawOffset() == rawOffset) { matches.add(id); } } catch (IOException e) { } } return matches.toArray(new String[matches.size()]); }
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; }
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; }