@Override public void setTimeZone(TimeZone zone) { fIcuSdf.setTimeZone(TimeZoneJDK.wrap(zone)); }
/** * Get current date and time as a timestamp. * @return urrent date and time as a timestamp. */ public static String getTimestamp() { // Use GMT timezone //timestampFormat.setTimeZone(TimeZone.getTimeZone("GMT")); timestampFormat.setTimeZone(TimeZone.getDefault()); // Return timestamp return timestampFormat.format(new Date()); }
/** * Get current date for default time zone. * @return current date for default time zone. */ public static String getDate() { // Use GMT timezone dateFormat.setTimeZone(TimeZone.getDefault()); // Return date return dateFormat.format(new Date()); }
/** * Get the given date and time as a timestamp. * @param date: a date object. * @return the given date and time as a timestamp. */ public static String getTimestamp(Date date) { timestampFormat.setTimeZone(TimeZone.getDefault()); return timestampFormat.format(date); } }
/** * Set the TimeZone for the calendar used by this DateIntervalFormat object. * @param zone The new TimeZone, will be cloned for use by this DateIntervalFormat. * @stable ICU 53 */ public void setTimeZone(TimeZone zone) { // zone is cloned once for all three usages below: TimeZone zoneToSet = (TimeZone)zone.clone(); if (fDateFormat != null) { fDateFormat.setTimeZone(zoneToSet); } // fDateFormat has the master calendar for the DateIntervalFormat; // fFromCalendar and fToCalendar are internal work clones of that calendar. if (fFromCalendar != null) { fFromCalendar.setTimeZone(zoneToSet); } if (fToCalendar != null) { fToCalendar.setTimeZone(zoneToSet); } }
private DateFormat createDateFormat() { ULocale locale = ULocale.forLanguageTag(this.locale); // calendar and numberingSystem are already handled in language-tag // assert locale.getKeywordValue("calendar").equals(calendar); // assert locale.getKeywordValue("numbers").equals(numberingSystem); SimpleDateFormat dateFormat = new SimpleDateFormat(pattern.get(), locale); if (timeZone != null) { dateFormat.setTimeZone(TimeZone.getTimeZone(timeZone)); } Calendar calendar = dateFormat.getCalendar(); if (calendar instanceof GregorianCalendar) { // format uses a proleptic Gregorian calendar with no year 0 GregorianCalendar gregorian = (GregorianCalendar) calendar; gregorian.setGregorianChange(new Date(Long.MIN_VALUE)); } return dateFormat; }
case ID_TIMEZONE: SimpleDateFormat dtf = new SimpleDateFormat("vvvv",locale); dtf.setTimeZone(TimeZone.getFrozenTimeZone(id)); result = dtf.format(new Date());