List of usage examples for org.joda.time DateTimeZone getAvailableIDs
public static Set<String> getAvailableIDs()
From source file:org.jboss.seam.international.datetimezone.AvailableDateTimeZones.java
License:Apache License
@SuppressWarnings("unchecked") @PostConstruct//from w w w . j a va2s . c om public void init() { dateTimeZones = new ArrayList<ForwardingDateTimeZone>(); final Set timeZoneIds = DateTimeZone.getAvailableIDs(); for (Object object : timeZoneIds) { String id = (String) object; if (id.matches(TIMEZONE_ID_PREFIXES)) { final DateTimeZone dtz = DateTimeZone.forID(id); dateTimeZones.add(new ForwardingDateTimeZone(id) { @Override protected DateTimeZone delegate() { return dtz; } }); } } Collections.sort(dateTimeZones, new Comparator<ForwardingDateTimeZone>() { public int compare(final ForwardingDateTimeZone a, final ForwardingDateTimeZone b) { return a.getID().compareTo(b.getID()); } }); dateTimeZones = Collections.unmodifiableList(dateTimeZones); }
From source file:org.joda.example.time.TimeZoneTable.java
License:Apache License
public static void main(String[] args) throws Exception { Set idSet = DateTimeZone.getAvailableIDs(); ZoneData[] zones = new ZoneData[idSet.size()]; {/*from w w w . ja v a 2 s. co m*/ Iterator it = idSet.iterator(); int i = 0; while (it.hasNext()) { String id = (String) it.next(); zones[i++] = new ZoneData(id, DateTimeZone.forID(id)); } Arrays.sort(zones); } PrintStream out = System.out; out.println("<table>"); out.println("<tr>" + "<th align=\"left\">Standard Offset</th>" + "<th align=\"left\">Canonical ID</th>" + "<th align=\"left\">Aliases</th>" + "</tr>"); ZoneData canonical = null; List<ZoneData> aliases = new ArrayList<ZoneData>(); for (int i = 0; i < zones.length; i++) { ZoneData zone = zones[i]; if (!zone.isCanonical()) { aliases.add(zone); continue; } if (canonical != null) { printRow(out, canonical, aliases); } canonical = zone; aliases.clear(); } if (canonical != null) { printRow(out, canonical, aliases); } out.println("</table>"); }
From source file:org.nodatime.tzvalidate.JodaDump.java
License:Open Source License
private static Map<String, DateTimeZone> getZones(String source) throws IOException { if (source == null) { return DateTimeZone.getAvailableIDs().stream().collect(Collectors.toMap(id -> id, DateTimeZone::forID)); }//from w w w .j av a 2 s . com File directory = new File(source); if (!directory.isDirectory()) { throw new IOException(directory + " is not a directory"); } File[] files = KNOWN_FILES.stream().map(f -> new File(directory, f)).toArray(File[]::new); ZoneInfoCompiler compiler = new ZoneInfoCompiler(); PrintStream out = System.out; // Ignore standard output while compiling... System.setOut(new PrintStream(new ByteArrayOutputStream())); Map<String, DateTimeZone> zones = compiler.compile(null, files); System.setOut(out); return zones; }
From source file:org.obm.push.protocol.data.ASTimeZoneConverterImpl.java
License:Open Source License
private Iterable<String> getAvailableTimeZoneIDs(ASTimeZone asTimeZone) { int rawOffset = -1 * toMillis(asTimeZone.getBias()); String[] availableIDs = TimeZone.getAvailableIDs(rawOffset); return FluentIterable.from(Arrays.asList(availableIDs)) .filter(Predicates.in(DateTimeZone.getAvailableIDs())).toSortedSet(new TimeZoneComparator()); }
From source file:org.openhab.io.caldav.internal.job.EventReloaderJob.java
License:Open Source License
private org.joda.time.DateTime getDateTime(String dateType, DateTime date, Date rangeDate) { org.joda.time.DateTime start;/* w w w . j a v a 2s. com*/ if (date.getTimeZone() == null) { if (date.isUtc()) { log.trace("{} is without timezone, but UTC", dateType); start = new org.joda.time.DateTime(rangeDate, DateTimeZone.UTC).toLocalDateTime() .toDateTime(CalDavLoaderImpl.defaultTimeZone); } else { log.trace("{} is without timezone, not UTC", dateType); start = new LocalDateTime(rangeDate).toDateTime(); } } else if (DateTimeZone.getAvailableIDs().contains(date.getTimeZone().getID())) { log.trace("{} is with known timezone: {}", dateType, date.getTimeZone().getID()); start = new org.joda.time.DateTime(rangeDate, DateTimeZone.forID(date.getTimeZone().getID())); } else { // unknown timezone log.trace("{} is with unknown timezone: {}", dateType, date.getTimeZone().getID()); start = new org.joda.time.DateTime(rangeDate, CalDavLoaderImpl.defaultTimeZone); } return start; }
From source file:org.opentestsystem.delivery.Sb11TimeZoneBuilder.java
License:Open Source License
@PostConstruct public void init() { //default to 'user' timezone which would be local server time, which gets replaced with the client's configured TZ if found. cachedDateTimeZone = CachedDateTimeZone.forZone(DateTimeZone.forID(System.getProperty("user.timezone"))); List<ClientEntity> clientEntityList = entityService.findAll(ClientEntity.FORMAT_TYPE); if (clientEntityList != null && !clientEntityList.isEmpty()) { ClientEntity clientEntity = clientEntityList.get(0); if (clientEntity.getTimeZone() != null && !clientEntity.getTimeZone().isEmpty()) { if (!DateTimeZone.getAvailableIDs().contains(clientEntity.getTimeZone())) { LOGGER.error("misconfiguration (invalid timezone id): " + clientEntity.getTimeZone()); } else { cachedDateTimeZone = CachedDateTimeZone.forZone(DateTimeZone.forID(clientEntity.getTimeZone())); }/* w w w. j a v a 2s. c o m*/ } } }
From source file:org.thelq.pircbotx.commands.NewYearsCommand.java
License:Open Source License
protected TreeMultimap<DateTime, DateTimeZone> getNyTimes() { synchronized (NEW_YEAR_ZONES) { if (NEW_YEAR_ZONES.isEmpty()) { NEW_YEAR_ZONES.put(getNow().plusMinutes(6), DateTimeZone.UTC); } else if (NEW_YEAR_ZONES.isEmpty()) //Generate for (String curId : DateTimeZone.getAvailableIDs()) { DateTimeZone tz = DateTimeZone.forID(curId); //Convert new years time relative to UTC DateTime nyTime = new DateTime(NEW_YEAR, 1, 1, 0, 0, 0, 0, tz); DateTime nyTimeUTC = nyTime.withZone(DateTimeZone.UTC); //Add to map NEW_YEAR_ZONES.get(nyTimeUTC).add(tz); }//from ww w. ja v a 2 s . c o m return NEW_YEAR_ZONES; } }
From source file:stroom.dashboard.server.FetchTimeZonesHandler.java
License:Apache License
@Override public TimeZoneData exec(final FetchTimeZonesAction action) { final List<String> ids = new ArrayList<>(DateTimeZone.getAvailableIDs()); Collections.sort(ids);/*from w w w . j a va 2s . co m*/ return new TimeZoneData(ids); }
From source file:us.physion.ovation.ui.editor.DatePickers.java
License:Open Source License
static String[] getTimeZoneIDs() { if (availableIDs == null) { ArrayList<String> ids = new ArrayList(DateTimeZone.getAvailableIDs()); Collections.sort(ids);// w ww. j a va 2s . co m availableIDs = ids.toArray(new String[ids.size()]); } return availableIDs; }