List of usage examples for java.util TimeZone SHORT
int SHORT
To view the source code for java.util TimeZone SHORT.
Click Source Link
getDisplayName()
indicating a short name, such as "PST." 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(true, TimeZone.SHORT); // checking display name System.out.println("Display name is :" + disname); }
From source file:Main.java
/** * @NAME getSimpleTZTag<br>//from ww w .j av a2s . c o m * getSimpleTZTag */ public static String getSimpleTZTag() { try { TimeZone tz = TimeZone.getDefault(); String s = "tz." + tz.getDisplayName(false, TimeZone.SHORT) + "tzid." + tz.getID(); return s; } catch (Exception e) { return ""; } }
From source file:Main.java
/** * Returns a formatted string representation of time in <code>milliseconds</code> * @param milliseconds Long value representing the time to be formatted * @return Formatted string representation of time in <code>milliseconds</code> *///from ww w . j a va2s. c o m public static String getOfxFormattedTime(long milliseconds) { Date date = new Date(milliseconds); String dateString = OFX_DATE_FORMATTER.format(date); TimeZone tz = Calendar.getInstance().getTimeZone(); int offset = tz.getRawOffset(); int hours = (int) ((offset / (1000 * 60 * 60)) % 24); String sign = offset > 0 ? "+" : ""; return dateString + "[" + sign + hours + ":" + tz.getDisplayName(false, TimeZone.SHORT, Locale.getDefault()) + "]"; }
From source file:org.openhab.binding.astro.internal.config.AstroThingConfig.java
/** * {@inheritDoc}/*from w w w .j a v a2s . c o m*/ */ @Override public String toString() { TimeZone tz = TimeZone.getDefault(); StringBuilder tzInfo = new StringBuilder(); tzInfo.append(tz.getID()); tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ") .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime())); tzInfo.append(")"); return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("thing", thingUid) .append("geolocation", geolocation).append("interval", interval) .append("systemTimezone", tzInfo.toString()) .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString(); }
From source file:org.eclipse.smarthome.binding.astro.internal.config.AstroThingConfig.java
@Override public String toString() { TimeZone tz = TimeZone.getDefault(); StringBuilder tzInfo = new StringBuilder(); tzInfo.append(tz.getID());// www .j av a2 s .c o m tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ") .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime())); tzInfo.append(")"); return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("thing", thingUid) .append("geolocation", geolocation).append("altitude", altitude).append("interval", interval) .append("systemTimezone", tzInfo.toString()) .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString(); }
From source file:com.haulmont.cuba.core.global.TimeZones.java
/** * @return short string representation of the given time zone *///from w ww. ja va2 s . c om public String getDisplayNameShort(@Nullable TimeZone timeZone) { if (timeZone == null) return ""; boolean dst = timeZone.inDaylightTime(timeSource.currentTimestamp()); String name = timeZone.getDisplayName(dst, TimeZone.SHORT); if (AD_HOC_TZ_PATTERN.matcher(name).matches()) return name; else return name + " (" + getDisplayOffset(timeZone) + ")"; }
From source file:com.github.hipchat.api.Room.java
public List<HistoryMessage> getHistory(Date date) { HipChat hc = getOrigin();//from w w w . j a v a2s .co m Calendar c = Calendar.getInstance(); String dateString = null; String tzString = null; if (date != null) { c.setTime(date); TimeZone tz = c.getTimeZone(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); dateString = sdf.format(date); tzString = tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT); } else { Date tDate = new Date(); c.setTime(tDate); TimeZone tz = c.getTimeZone(); dateString = "recent"; tzString = tz.getDisplayName(tz.inDaylightTime(tDate), TimeZone.SHORT); } String query = String.format(HipChatConstants.ROOMS_HISTORY_QUERY_FORMAT, getId(), dateString, tzString, HipChatConstants.JSON_FORMAT, hc.getAuthToken()); OutputStream output = null; InputStream input = null; HttpURLConnection connection = null; List<HistoryMessage> messages = null; try { URL requestUrl = new URL(HipChatConstants.API_BASE + HipChatConstants.ROOMS_HISTORY + query); connection = (HttpURLConnection) requestUrl.openConnection(); connection.setDoInput(true); input = connection.getInputStream(); messages = MessageParser.parseRoomHistory(this, input); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(output); connection.disconnect(); } return messages; }
From source file:org.openhab.binding.astro.internal.common.AstroConfig.java
@Override public String toString() { String intervallMessage = (interval == 0 ? "disabled" : String.valueOf(interval)); TimeZone tz = TimeZone.getDefault(); StringBuilder tzInfo = new StringBuilder(); tzInfo.append(tz.getID());// ww w .j a v a 2 s .co m tzInfo.append(" (").append(tz.getDisplayName(false, TimeZone.SHORT)).append(" ") .append(new SimpleDateFormat("Z").format(Calendar.getInstance().getTime())); tzInfo.append(")"); return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("latitude", latitude) .append("longitude", longitude).append("interval", intervallMessage) .append("systemTimezone", tzInfo.toString()) .append("daylightSavings", Calendar.getInstance().get(Calendar.DST_OFFSET) != 0).toString(); }
From source file:org.apache.accumulo.monitor.servlets.DefaultServlet.java
/** * Shows the current time zone (based on the current time) short name *//*from w w w . ja va 2 s.c o m*/ private static String getShortTZName() { TimeZone tz = TimeZone.getDefault(); return tz.getDisplayName(tz.inDaylightTime(new Date()), TimeZone.SHORT); }
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());/*from w w w.j av a2 s . com*/ 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; }