List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:Main.java
public static long getCurrentTimestamp() { return Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis(); }
From source file:Main.java
public static Calendar getCalendar(Date date) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(date);/* w ww .j a v a 2s . c o m*/ return cal; }
From source file:Main.java
public static int calculateDayOfWeek(Date date) { final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.setTime(date);/*from www . ja v a2 s . c om*/ return calendar.get(Calendar.DAY_OF_WEEK); }
From source file:Main.java
public static long getTimeStampStartOfDay(long time) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.setTime(new Date(time)); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0);/*from w w w . j a v a 2 s . co m*/ cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTimeInMillis(); }
From source file:Main.java
public static String getTodayDate() { TimeZone currZone = TimeZone.getTimeZone("Asia/Singapore"); Calendar myCal = Calendar.getInstance(currZone, new Locale("en")); SimpleDateFormat sdf = new SimpleDateFormat(); sdf.applyPattern("yyyy-MM-dd"); return (sdf.format(myCal.getTime())); }
From source file:Main.java
public static Date getCurrentUTCTime() { // Set device's time zone to UTC TimeZone.setDefault(TimeZone.getTimeZone("UTC")); Calendar calendar = Calendar.getInstance(); return calendar.getTime(); }
From source file:Main.java
public static boolean isInEasternEightZones() { boolean defaultVaule = true; if (TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08")) defaultVaule = true;/*from www .j a va 2s . c o m*/ else defaultVaule = false; return defaultVaule; }
From source file:Main.java
private static int getDiffTimeZoneRawOffset() { return TimeZone.getDefault().getRawOffset() - TimeZone.getTimeZone(GMT).getRawOffset(); }
From source file:Main.java
public final static String now() { TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(tz);// www . j a v a 2 s.com return df.format(new Date()); }
From source file:Main.java
public static SimpleDateFormat getDateFormat() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); format.setTimeZone(TimeZone.getTimeZone("UTC")); return format; }