List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:Main.java
public static String getTimeStamp() { Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("h:mm aa dd-M-yyyy"); simpleDateFormat.setTimeZone(TimeZone.getDefault()); return simpleDateFormat.format(calendar.getTime()); }
From source file:Main.java
public static String getTimeStamp() { Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getDefault()); return simpleDateFormat.format(calendar.getTime()); }
From source file:Main.java
public static String getTimeStamp() { Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); simpleDateFormat.setTimeZone(TimeZone.getDefault()); return simpleDateFormat.format(calendar.getTime()); }
From source file:Main.java
public static Date receiverTimeToDate(long delta) { int currentTZOffset = TimeZone.getDefault().getRawOffset(); long epochMS = 1230768000000L; // Jan 01, 2009 00:00 in UTC long milliseconds = epochMS - currentTZOffset; long timeAdd = milliseconds + (1000L * delta); TimeZone tz = TimeZone.getDefault(); if (tz.inDaylightTime(new Date())) timeAdd = timeAdd - (1000 * 60 * 60); return new Date(timeAdd); }
From source file:Main.java
public static String getWochentagFromSystemDate() { Calendar rightNow = Calendar.getInstance(TimeZone.getDefault()); int dayOfWeek = rightNow.get(Calendar.DAY_OF_WEEK); switch (dayOfWeek) { case 1://from w w w . j av a 2 s. c om return "Sonntag"; case 2: return "Montag"; case 3: return "Dienstag"; case 4: return "Mittwoch"; case 5: return "Donnerstag"; case 6: return "Freitag"; case 7: return "Samstag"; } return ""; }
From source file:Main.java
public static String toIsoDateFormat(Date date) { TimeZone timeZone = TimeZone.getDefault(); boolean utc = TimeZone.getTimeZone("UTC").equals(timeZone) || TimeZone.getTimeZone("GMT").equals(timeZone); String pattern = utc ? "yyyy-MM-dd'T'HH:mm:ss'Z'" : "yyyy-MM-dd'T'HH:mm:ssZ"; SimpleDateFormat format = new SimpleDateFormat(pattern); format.setTimeZone(timeZone);/*from www .j a va 2 s.c o m*/ StringBuilder buffer = new StringBuilder(format.format(date)); if (!utc) { buffer.insert(buffer.length() - 2, ':'); } return buffer.toString(); }
From source file:Main.java
/** * Returns the default time zone ID for calendar * * @return default time zone ID/* ww w . j a v a2 s. c o m*/ */ public static String getTimeZoneId() { return TimeZone.getDefault().getID(); }
From source file:Main.java
public static String getTimeStampForDatabase() { Calendar calendar = Calendar.getInstance(TimeZone.getDefault()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getDefault()); return simpleDateFormat.format(calendar.getTime()); }
From source file:Main.java
public static int todayLocal() { return dayFrom_Milliseconds(System.currentTimeMillis() + TimeZone.getDefault().getRawOffset()); }
From source file:Main.java
public static String getUserPhoneTimezone() { TimeZone timeZone = TimeZone.getDefault(); timeZone = timeZone.getTimeZone(timeZone.getID()); Date date = new Date(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); df.setTimeZone(timeZone);//ww w .ja va2 s.co m return df.format(date); }