List of usage examples for java.util TimeZone getAvailableIDs
public static synchronized String[] getAvailableIDs()
From source file:com.microsoft.exchange.DateHelpTest.java
@Test public void systemTimeZone() { List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs()); assertFalse(CollectionUtils.isEmpty(availableIDs)); assertTrue(availableIDs.contains(TimeZones.UTC_ID)); assertTrue(availableIDs.contains("UTC")); TimeZone ical4jUTC = TimeZone.getTimeZone(TimeZones.UTC_ID); TimeZone sysUTC = TimeZone.getTimeZone("UTC"); assertEquals(ical4jUTC.getDSTSavings(), sysUTC.getDSTSavings()); assertEquals(ical4jUTC.getRawOffset(), sysUTC.getRawOffset()); assertTrue(ical4jUTC.hasSameRules(sysUTC)); TimeZone origDefaultTimeZone = TimeZone.getDefault(); assertNotNull(origDefaultTimeZone);/*from w w w .j ava 2 s.c o m*/ assertEquals(TimeZone.getDefault().getRawOffset(), origDefaultTimeZone.getRawOffset()); log.info("TimeZone.DisplayName=" + origDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + origDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + origDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + origDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + origDefaultTimeZone.useDaylightTime()); TimeZone.setDefault(ical4jUTC); assertEquals(ical4jUTC, TimeZone.getDefault()); log.info(" -- Defualt Time Zone has been changed successfully! -- "); TimeZone newDefaultTimeZone = TimeZone.getDefault(); log.info("TimeZone.DisplayName=" + newDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + newDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + newDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + newDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + newDefaultTimeZone.useDaylightTime()); }
From source file:microsoft.exchange.webservices.data.property.complex.OlsonTimeZoneTest.java
@Test public void testOlsonTimeZoneConversion() { final Map<String, String> olsonTimeZoneToMsMap = TimeZoneUtils.createOlsonTimeZoneToMsMap(); final String[] timeZoneIds = TimeZone.getAvailableIDs(); for (final String timeZoneId : timeZoneIds) { final boolean america = timeZoneId.startsWith("America"); final boolean europe = timeZoneId.startsWith("Europe"); final boolean africa = timeZoneId.startsWith("Africa"); if (america || europe || africa) { // There are a few timezones that are out of date or don't have direct microsoft mappings // according to the Unicode source we use so we will only test Americas, Europe and Africa. final TimeZone timeZone = TimeZone.getTimeZone(timeZoneId); final OlsonTimeZoneDefinition olsonTimeZone = new OlsonTimeZoneDefinition(timeZone); final String olsonTimeZoneId = olsonTimeZone.getId(); Assert.assertFalse(StringUtils.isBlank(olsonTimeZoneId)); Assert.assertEquals(olsonTimeZoneToMsMap.get(timeZoneId), olsonTimeZoneId); }/*from w w w. ja v a2s . c o m*/ } }
From source file:com.netflix.spinnaker.halyard.config.validate.v1.DeploymentConfigurationValidator.java
@Override public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) { String timezone = n.getTimezone(); if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) { p.addProblem(Problem.Severity.ERROR, "Timezone " + timezone + " does not match any known canonical timezone ID").setRemediation( "Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones"); }/*from w w w. ja va 2s. c o m*/ String version = n.getVersion(); Versions versions = versionsService.getVersions(); if (StringUtils.isEmpty(version)) { p.addProblem(Problem.Severity.WARNING, "You have not yet selected a version of Spinnaker to deploy.", "version"); return; } Optional<Versions.IllegalVersion> illegalVersion = versions.getIllegalVersions().stream() .filter(v -> v.getVersion().equals(version)).findAny(); if (illegalVersion.isPresent()) { p.addProblem(Problem.Severity.ERROR, "Version \"" + version + "\" may no longer be deployed with Halyard: " + illegalVersion.get().getReason()); return; } try { versionsService.getBillOfMaterials(version); } catch (HalException e) { p.extend(e); return; } catch (Exception e) { p.addProblem(Problem.Severity.FATAL, "Unexpected error trying to validate version \"" + version + "\": " + e.getMessage(), "version"); return; } boolean isReleased = versions.getVersions().stream().anyMatch(v -> Objects.equals(v.getVersion(), version)); if (!isReleased) { // Checks if version is of the form X.Y.Z if (version.matches("\\d+\\.\\d+\\.\\d+")) { String majorMinor = Versions.toMajorMinor(version); Optional<Versions.Version> patchVersion = versions.getVersions().stream() .map(v -> new ImmutablePair<>(v, Versions.toMajorMinor(v.getVersion()))) .filter(v -> v.getRight() != null).filter(v -> v.getRight().equals(majorMinor)) .map(ImmutablePair::getLeft).findFirst(); if (patchVersion.isPresent()) { p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" was patched by \"" + patchVersion.get().getVersion() + "\". Please upgrade when possible.") .setRemediation("https://spinnaker.io/setup/install/upgrades/"); } else { p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is no longer supported by the Spinnaker team. Please upgrade when possible.") .setRemediation("https://spinnaker.io/setup/install/upgrades/"); } } else { p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is not a released (validated) version of Spinnaker.", "version"); } } }
From source file:ching.icecreaming.action.TimeZones.java
@Action(value = "time-zones", results = { @Result(name = "success", location = "json.jsp") }) public String execute() { String[] array1 = TimeZone.getAvailableIDs(); List<String> list1 = Arrays.asList(array1); Arrays.sort(array1);/*from w w w .j a va2 s. com*/ Map<String, List<String>> map0 = new HashMap<String, List<String>>(); map0.put("timeZones", list1); Gson gson = new GsonBuilder().create(); jsonData = gson.toJson(map0); return SUCCESS; }
From source file:com.jaspersoft.jasperserver.war.common.JdkTimeZonesList.java
public void afterPropertiesSet() throws Exception { if (timeZonesIds == null) { String[] availableIDs = TimeZone.getAvailableIDs(); timeZonesIds = Arrays.asList(availableIDs); }/*from w w w.j a va2 s . c om*/ }
From source file:org.sisto.jeeplate.jsf.Oracle.java
private void populateTimezones() { String[] allTimezones = TimeZone.getAvailableIDs(); this.timezones.put("UTC", "UTC"); for (String timezone : allTimezones) { if (timezone.startsWith("SystemV/")) { continue; } else if (timezone.startsWith("Etc/")) { continue; } else if (timezone.contains("/")) { this.timezones.put(timezone, timezone); } else {/*w ww . ja va2s . c om*/ continue; } } }
From source file:org.nuxeo.ecm.user.center.profile.TimeZones.java
private void initTimeZones() { timeZoneSelectItems = new ArrayList<SelectItem>(); final String[] timeZoneIds = TimeZone.getAvailableIDs(); for (final String id : timeZoneIds) { timeZoneSelectItems.add(new SelectItem(id, displayTimeZone(id))); }/*from w w w. j ava 2 s. c o m*/ Collections.sort(timeZoneSelectItems, new Comparator<SelectItem>() { @Override public int compare(SelectItem o1, SelectItem o2) { return ((String) o1.getValue()).compareTo((String) o2.getValue()); } }); }
From source file:com.jdo.CloudContactUtils.java
public static void main(String[] args) { // //from www .j a va 2s . c o m // List<CloudContactNotification> lc=new ArrayList<CloudContactNotification>(); // CloudContactNotification a=new CloudContactNotification(); // a.setLastAccess(""+new Date().getTime()); // a.setText("tt"); // a.setUserName("dhaneesh"); // lc.add(a); // // System.out.println(JSONObject.wrap(lc)); // try { //Asia/Calcutta String[] allTimeZones = TimeZone.getAvailableIDs(); Date now = new Date(); for (int i = 0; i < allTimeZones.length; i++) { //System.out.println(allTimeZones[i]); TimeZone tz = TimeZone.getTimeZone(allTimeZones[i]); System.out.format("%s;%s; %f \n", allTimeZones[i], tz.getDisplayName(), (float) (tz.getOffset(now.getTime()) / 3600000.0)); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:io.github.sparta.helpers.date.DateUtil.java
/** * Get time zones./*from w w w . j av a 2s. c o m*/ * * @return map typezone id and GMT */ public static Map<String, String> getFilteredTimeZoneMap() { if (timezoneIDMap == null) { timezoneIDMap = new LinkedHashMap<String, String>(); String[] ids = TimeZone.getAvailableIDs(); for (String id : ids) { TimeZone zone = TimeZone.getTimeZone(id); int offset = zone.getRawOffset(); int offsetSecond = offset / CONSTANT_1000; int hour = offsetSecond / (CONSTANT_60 * CONSTANT_60); int minutes = (offsetSecond % (CONSTANT_60 * CONSTANT_60)) / CONSTANT_60; timezoneIDMap.put(TimeZone.getTimeZone(id).getDisplayName(), String.format("(GMT%+d:%02d) %s", hour, minutes, id)); } } return timezoneIDMap; }
From source file:com.mtt.myapp.home.controller.HomeController.java
/** * Initialize {@link HomeController}.//w ww.ja va2s . c om */ @PostConstruct public void init() { timeZones = new ArrayList<TimeZone>(); final String[] timeZoneIds = TimeZone.getAvailableIDs(); for (final String id : timeZoneIds) { if (id.matches(TIMEZONE_ID_PREFIXES) && !TimeZone.getTimeZone(id).getDisplayName().contains("GMT")) { timeZones.add(TimeZone.getTimeZone(id)); } } Collections.sort(timeZones, new Comparator<TimeZone>() { public int compare(final TimeZone a, final TimeZone b) { return a.getID().compareTo(b.getID()); } }); scheduledTaskService.runAsync(new Runnable() { @Override public void run() { getLeftPanelEntries(); getRightPanelEntries(); } }); }