List of usage examples for org.joda.time DateTimeZone getAvailableIDs
public static Set<String> getAvailableIDs()
From source file:TimeZoneListJson.java
License:Mozilla Public License
public static void main(String[] args) throws Exception { Set idSet = DateTimeZone.getAvailableIDs(); LinkedHashMap<String, ArrayList<ZoneData>> zones = new LinkedHashMap<String, ArrayList<ZoneData>>(); {/*from ww w . j a v a2 s. co m*/ Iterator it = idSet.iterator(); int i = 0; while (it.hasNext()) { String id = (String) it.next(); // get only standard format (not stuff like Etc/GMT-xx, PST, etc.) if (id.matches("^[A-Za-z_-]+?/[A-Za-z_-]+?(/[A-Za-z_-]+?)?") && !id.matches("^Etc/[A-Za-z0-9_-]+?")) { String k = id.split("/")[0]; if (zones.containsKey(k)) { zones.get(k).add(new ZoneData(id, DateTimeZone.forID(id))); } else { ArrayList<ZoneData> regionZones = new ArrayList<ZoneData>(); regionZones.add(new ZoneData(id, DateTimeZone.forID(id))); zones.put(k, regionZones); } } } // add UTC ArrayList<ZoneData> otherZones = new ArrayList<ZoneData>(); otherZones.add(new ZoneData("UTC", DateTimeZone.forID("UTC"))); zones.put("Other", otherZones); } PrintStream out = System.out; out.println("{"); for (Map.Entry<String, ArrayList<ZoneData>> entry : zones.entrySet()) { // skip 'empty' regions where no canonical zone is present boolean hasCanonicalZone = false; for (ZoneData z : entry.getValue()) { if (z.isCanonical()) { hasCanonicalZone = true; break; } } if (!hasCanonicalZone) continue; // sort by std offset Collections.sort(entry.getValue()); out.println(entry.getKey() + ": {"); for (ZoneData z : entry.getValue()) { if (z.isCanonical()) { printRow(out, z); } } out.println("},"); } out.println("};"); }
From source file:AgeCalculator.java
License:Apache License
private void addTopArea(Container container) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(fixedHeight(new JLabel("Birthdate"))); panel.add(Box.createHorizontalStrut(10)); final JTextField birthdateField = new JTextField(iBirthdateStr + ' '); Document doc = birthdateField.getDocument(); doc.addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent e) { update(e);//www . j a va2s. c o m } public void removeUpdate(DocumentEvent e) { update(e); } public void changedUpdate(DocumentEvent e) { update(e); } private void update(DocumentEvent e) { iBirthdateStr = birthdateField.getText(); updateResults(); } }); panel.add(fixedHeight(birthdateField)); panel.add(Box.createHorizontalStrut(10)); Object[] ids = DateTimeZone.getAvailableIDs().toArray(); final JComboBox zoneSelector = new JComboBox(ids); zoneSelector.setSelectedItem(DateTimeZone.getDefault().getID()); panel.add(fixedSize(zoneSelector)); zoneSelector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String id = (String) zoneSelector.getSelectedItem(); iChronology = ISOChronology.getInstance(DateTimeZone.forID(id)); updateResults(); } }); container.add(fixedHeight(panel)); }
From source file:cmg.org.monitor.ext.util.DateTimeUtils.java
License:Open Source License
public static String[] listAllTimeZone() { Object obj = MonitorMemcache.get(Key.create(Key.LIST_AVAILABLE_TIME_ZONE)); List<String> list = null; Gson gson = new Gson(); if (obj != null && obj instanceof String) { Type type = new TypeToken<Collection<String>>() { }.getType();/*w w w. j ava2 s. co m*/ list = gson.fromJson(String.valueOf(obj), type); } else { Set<String> listTemp = DateTimeZone.getAvailableIDs(); if (listTemp != null && listTemp.size() > 0) { list = new ArrayList<String>(); for (String t : listTemp) { list.add(t); } } MonitorMemcache.put(Key.create(Key.LIST_AVAILABLE_TIME_ZONE), gson.toJson(list)); } if (list != null && !list.isEmpty()) { String[] temp = new String[list.size()]; list.toArray(temp); return temp; } return null; }
From source file:com.enitalk.controllers.bots.TimeZoneTestr.java
public static void main(String[] args) { Set<String> ids = DateTimeZone.getAvailableIDs(); TreeMultimap<Long, String> map = TreeMultimap.create(); for (String id : ids) { DateTimeZone dz = DateTimeZone.forID(id); int offset = dz.getOffset(DateTime.now().withZone(DateTimeZone.UTC)); map.put(TimeUnit.MILLISECONDS.toMinutes(offset), id); }/*w w w . ja va 2s . co m*/ ObjectMapper j = new ObjectMapper(); ArrayNode a = j.createArrayNode(); map.keySet().forEach((Long key) -> { a.addObject().set(key.toString(), j.convertValue(map.get(key), ArrayNode.class)); }); System.out.println(a); // System.out.println(map); }
From source file:com.enonic.cms.business.timezone.TimeZoneServiceImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) public void afterPropertiesSet() throws Exception { Set<String> ids = DateTimeZone.getAvailableIDs(); timeZones.add(DateTimeZone.UTC);/*from ww w.java 2 s . c o m*/ for (String id : ids) { if (!id.equals("UTC")) { timeZones.add(DateTimeZone.forID(id)); } } }
From source file:com.enonic.cms.core.timezone.TimeZoneServiceImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) public TimeZoneServiceImpl() { Set<String> ids = DateTimeZone.getAvailableIDs(); this.timeZones.add(DateTimeZone.UTC); for (final String id : ids) { if (!id.equals("UTC")) { this.timeZones.add(DateTimeZone.forID(id)); }/*from w w w . ja v a 2 s.c om*/ } }
From source file:com.facebook.presto.util.GenerateTimeZoneIndex.java
License:Apache License
public static void main(String[] args) throws InterruptedException { ///* w w w .java 2 s.c o m*/ // Header // System.out.println("#"); System.out.println("# DO NOT REMOVE OR MODIFY EXISTING ENTRIES"); System.out.println("#"); System.out.println("# This file contain the fixed numeric id of every supported time zone id."); System.out.println("# Every zone id in this file must be supported by java.util.TimeZone and the"); System.out.println("# Joda time library. This is because Presto uses both java.util.TimeZone and"); System.out.println("# the Joda time## for during execution."); System.out.println("#"); System.out.println("# suppress inspection \"UnusedProperty\" for whole file"); // // We assume 0 is UTC and do not generate it // // // Negative offset // short nextZoneKey = 1; for (int offset = 14 * 60; offset > 0; offset--) { String zoneId = String.format("-%02d:%02d", offset / 60, abs(offset % 60)); short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // Positive offset // for (int offset = 1; offset <= 14 * 60; offset++) { String zoneId = String.format("+%02d:%02d", offset / 60, abs(offset % 60)); short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // IANA regional zones: region/city // TreeSet<String> jodaZones = new TreeSet<>(DateTimeZone.getAvailableIDs()); TreeSet<String> jdkZones = new TreeSet<>(Arrays.asList(TimeZone.getAvailableIDs())); TreeSet<String> zoneIds = new TreeSet<>(filter(intersection(jodaZones, jdkZones), not(ignoredZone()))); for (String zoneId : zoneIds) { if (zoneId.indexOf('/') < 0) { continue; } short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } // // Other zones // for (String zoneId : zoneIds) { if (zoneId.indexOf('/') >= 0) { continue; } short zoneKey = nextZoneKey++; System.out.println(zoneKey + " " + zoneId); } System.out.println(); System.out.println("# Zones not supported in Java"); for (String invalidZone : filter(Sets.difference(jodaZones, jdkZones), not(ignoredZone()))) { System.out.println("# " + invalidZone); } System.out.println(); System.out.println("# Zones not supported in Joda"); for (String invalidZone : filter(Sets.difference(jdkZones, jodaZones), not(ignoredZone()))) { System.out.println("# " + invalidZone); } Thread.sleep(1000); }
From source file:com.hangum.tadpole.engine.utils.TimeZoneUtil.java
License:Open Source License
/** * timezone list * * @return */ public static Set<String> getTimezoneList() { return DateTimeZone.getAvailableIDs(); }
From source file:com.loadtesting.showcase.springmvc.model.converter.JodaTimeConverter.java
License:Apache License
public JodaTimeConverter(String pattern) { this.map = new ConcurrentHashMap<DateTimeZone, DateTimeFormatter>(DateTimeZone.getAvailableIDs().size()); this.pattern = pattern; }
From source file:de.brazzy.nikki.view.ScanOptions.java
License:Open Source License
/** * @param selected// www .jav a 2s. co m * preselected time zone */ public ScanOptions(DateTimeZone selected) { @SuppressWarnings("unchecked") String[] zones = (String[]) DateTimeZone.getAvailableIDs().toArray(new String[0]); Arrays.sort(zones); combobox.setModel(new DefaultComboBoxModel(zones)); if (selected != null) { combobox.setSelectedItem(selected.getID()); } else { combobox.setSelectedItem(null); } add(new JLabel(Texts.Dialogs.ScanOptions.TIMEZONE_LABEL)); add(combobox); }