List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:Main.java
public static DateFormat createUrlDateFormat() { DateFormat df = new SimpleDateFormat(urlDateString); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df;//from w ww. j a v a2 s . c o m }
From source file:Main.java
/** * Parse a time character array as defined in PKCS#11 and return is as a * Date object./*w w w.j a v a2 s . c om*/ * * @param timeChars A time encoded as character array as specified in PKCS#11. * @return A Date object set to the time indicated in the given char-array. * null, if the given char array is null or the format is wrong. * @preconditions * @postconditions */ public static Date parseTime(char[] timeChars) { Date time = null; if ((timeChars != null) && timeChars.length > 2) { String timeString = new String(timeChars, 0, timeChars.length - 2); try { SimpleDateFormat utc = new SimpleDateFormat("yyyyMMddhhmmss"); utc.setTimeZone(TimeZone.getTimeZone("UTC")); time = utc.parse(timeString); // time = new SimpleDateFormat("yyyyMMddhhmmss").parse(timeString); } catch (ParseException ex) { /* nothing else to be done */ } } return time; }
From source file:Main.java
public static long convertTime(long time) { GregorianCalendar t1 = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); t1.setTimeInMillis(time);/* w w w . j ava 2 s .c o m*/ GregorianCalendar t2 = new GregorianCalendar(); t2.set(t1.get(GregorianCalendar.YEAR), t1.get(GregorianCalendar.MONTH), t1.get(GregorianCalendar.DAY_OF_MONTH), t1.get(GregorianCalendar.HOUR_OF_DAY), t1.get(GregorianCalendar.MINUTE), t1.get(GregorianCalendar.SECOND)); return t2.getTimeInMillis(); }
From source file:Main.java
public static DateFormat createLocalDateFormat() { DateFormat df = new SimpleDateFormat(localDateTimeFormatString); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df;//from ww w . j av a 2 s.c o m }
From source file:Main.java
public static String getWeekDay(Date date) { DateFormat df = new SimpleDateFormat(weekDayString, Locale.UK); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); }
From source file:Main.java
public static String getMonthDay(Date date) { DateFormat df = new SimpleDateFormat(monthDayString, Locale.UK); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); }
From source file:Main.java
public static String toSimpleDateTime(Date date) { DateFormat df = new SimpleDateFormat(simpleDateString, Locale.UK); df.setTimeZone(TimeZone.getTimeZone("UTC")); return df.format(date); }
From source file:net.portalblockz.portalbot.Utils.java
public static String getDate() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); return sdf.format(calendar.getTime()); }
From source file:Main.java
public static String getFormattedDate(Long millis, String timeZone) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US); if (!TextUtils.isEmpty(timeZone)) sdf.setTimeZone(TimeZone.getTimeZone(timeZone)); return millis != null ? sdf.format(new Date(millis)) : ""; }
From source file:Main.java
public static TimeZone getTimeZone(final String id) { if (id == null) return TimeZone.getDefault(); else/* www . j av a 2 s . c om*/ return TimeZone.getTimeZone(id); }