List of usage examples for java.util TimeZone getDisplayName
public final String getDisplayName()
From source file:Main.java
public static void main(String[] args) { Calendar now = Calendar.getInstance(); TimeZone timeZone = now.getTimeZone(); System.out.println("Current TimeZone is : " + timeZone.getDisplayName()); }
From source file:Main.java
public static void main(String args[]) { // create default time zone object TimeZone timezonedefault = TimeZone.getDefault(); // get display name String disname = timezonedefault.getDisplayName(); // checking display name System.out.println("Display name is :" + disname); }
From source file:Main.java
public static void main(String[] args) { // create a calendar Calendar cal = Calendar.getInstance(); // get the time zone TimeZone tz = cal.getTimeZone(); // print the time zone name for this calendar System.out.println("The time zone is :" + tz.getDisplayName()); }
From source file:Main.java
public static void main(String[] args) { // create a calendar Locale locale1 = Locale.CANADA; TimeZone tz1 = TimeZone.getTimeZone("GMT"); Calendar cal1 = Calendar.getInstance(tz1, locale1); // display time zone for both calendars String tzname1 = tz1.getDisplayName(); String name1 = locale1.getDisplayName(); System.out.println("GMT and Canada: " + tzname1 + " " + name1); }
From source file:com.jdo.CloudContactUtils.java
public static void main(String[] args) { // //from w w w . j a v a 2s . co 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:com.hurence.logisland.utils.DateUtils.java
public static String outputDateInfo(Date d) { String output = ""; Calendar c = GregorianCalendar.getInstance(tz); c.setTimeInMillis(d.getTime());/*www .ja v a 2s . c o m*/ TimeZone tzCal = c.getTimeZone(); output += "Date: " + d + "\n"; // toString uses current system TimeZone output += "Date Millis: " + d.getTime() + "\n"; output += "Cal Millis: " + c.getTimeInMillis() + "\n"; output += "Cal To Date Millis: " + c.getTime().getTime() + "\n"; output += "Cal TimeZone Name: " + tzCal.getDisplayName() + "\n"; output += "Cal TimeZone ID: " + tzCal.getID() + "\n"; output += "Cal TimeZone DST Name: " + tzCal.getDisplayName(true, TimeZone.SHORT) + "\n"; output += "Cal TimeZone Standard Name: " + tzCal.getDisplayName(false, TimeZone.SHORT) + "\n"; output += "In DayLight: " + tzCal.inDaylightTime(d) + "\n"; output += "" + "\n"; output += "Day Of Month: " + c.get(Calendar.DAY_OF_MONTH) + "\n"; output += "Month Of Year: " + c.get(Calendar.MONTH) + "\n"; output += "Year: " + c.get(Calendar.YEAR) + "\n"; output += "Hour Of Day: " + c.get(Calendar.HOUR_OF_DAY) + "\n"; output += "Minute: " + c.get(Calendar.MINUTE) + "\n"; output += "Second: " + c.get(Calendar.SECOND) + "\n"; return output; }
From source file:com.boundlessgeo.geoserver.api.controllers.IO.java
static private Object safeValue(Object value) { if (value == null) { return null; }/*from w w w . j a va2s .c o m*/ if (value instanceof String || value instanceof Number || value instanceof Boolean) { return value; } if (value instanceof java.util.TimeZone) { TimeZone zone = (TimeZone) value; return zone.getDisplayName(); } return value.toString(); }
From source file:org.springframework.xd.shell.command.ConfigCommands.java
/** * Allows for setting the {@link TimeZone} via a Spring XD Shell command. *//*from ww w .j a v a 2s . com*/ @CliCommand(value = "admin config timezone set", help = "Set the timezone of the Spring XD Shell (Not persisted)") public String setTimeZone( @CliOption(mandatory = true, key = { "", "timeZone" }, help = "the id of the timezone, " + "You can obtain a list of timezone ids using 'admin config timezone list', " + "If an invalid timezone id is provided, then 'Greenwich Mean Time' " + "is being used") String timeZoneId) { final TimeZone newCientTimeZone = TimeZone.getTimeZone(timeZoneId); this.configuration.setClientTimeZone(newCientTimeZone); return "TimeZone set to " + newCientTimeZone.getDisplayName(); }
From source file:org.kalypso.model.hydrology.internal.postprocessing.statistics.NAStatistics.java
private void writeCsv(final IObservation observation, final File reportDir) throws IOException, SensorException { final File reportFileCSV = new File(reportDir, FILENAME_CSV); final ITupleModel values = observation.getValues(null); final IAxis[] resultAxisList = observation.getAxes(); final TimeZone timeZone = KalypsoCorePlugin.getDefault().getTimeZone(); final String timezoneName = timeZone.getDisplayName(); try (PrintWriter pw = new PrintWriter(reportFileCSV)) { /* Header */ pw.print(Messages.getString("NAStatistics.1")); //$NON-NLS-1$ pw.print(SEPARATOR_CSV);/*from www . j a v a 2 s .c o m*/ pw.print(Messages.getString("NAStatistics.2")); //$NON-NLS-1$ pw.print(SEPARATOR_CSV); pw.format(Messages.getString("NAStatistics.3"), timezoneName); //$NON-NLS-1$ pw.print(SEPARATOR_CSV); pw.print(Messages.getString("NAStatistics.4")); //$NON-NLS-1$ pw.print(SEPARATOR_CSV); pw.print(Messages.getString("NAStatistics.5")); //$NON-NLS-1$ pw.print(SEPARATOR_CSV); pw.println(Messages.getString("NAStatistics.6")); //$NON-NLS-1$ // REMARK/BUGFIX: using the default charset here, because this file is usually intended to be opened with excel // Excel automatically assumes the default charset of the platform for (int i = 0; i < values.size(); i++) { for (int j = 0; j < 6; j++) { final Object currentElement = values.get(i, resultAxisList[j]); final String asText = asText(currentElement, j); pw.print(asText); if (j == 5) pw.format("%n"); //$NON-NLS-1$ else pw.print(SEPARATOR_CSV); } } pw.flush(); pw.close(); } }
From source file:org.openmrs.module.atomfeed.AtomFeedUtilTest.java
/** * @see AtomFeedUtil#dateToRFC3339(Date) * @verifies convert date to rfc/*from www . jav a 2 s . co m*/ */ @Test public void dateToRFC3339_shouldConvertDateToRfc() throws Exception { TimeZone tz = TimeZone.getDefault(); System.out.println("timezone: " + tz.getDisplayName()); try { TimeZone.setDefault(TimeZone.getTimeZone("Europe/Helsinki")); String expectedOutput = "2012-05-08T22:39:54+03:00"; Date date = new Date(1336505994083l); Assert.assertEquals(expectedOutput, AtomFeedUtil.dateToRFC3339(date)); } finally { TimeZone.setDefault(tz); // reset back to what it was } }