List of usage examples for java.util TimeZone getTimeZone
public static TimeZone getTimeZone(ZoneId zoneId)
From source file:Main.java
public static String TimeToString(Date d) { DateFormat formatter;/*from w w w .j av a 2 s .c om*/ formatter = new SimpleDateFormat("HH-mm"); formatter.setTimeZone(TimeZone.getTimeZone("EST")); String s = new StringBuilder(formatter.format(d)).toString(); return s; }
From source file:Main.java
public static String getDate(String integer) { SimpleDateFormat sdf = new SimpleDateFormat("EEEE,MMMM d,yyyy h:mm,a", Locale.ENGLISH); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); String formattedDate = sdf.format(new Date()); if (!integer.equalsIgnoreCase("null")) { long seconds = Integer.valueOf(integer); long millis = seconds * 1000; Date date = new Date(millis); formattedDate = sdf.format(date); return formattedDate; }/* w w w . jav a 2 s .c om*/ return formattedDate; }
From source file:Main.java
public static String DateTimeToString(Date d) { DateFormat formatter;//from w w w. j a va2 s. c o m formatter = new SimpleDateFormat("dd-MM-yyyy-HH-mm"); formatter.setTimeZone(TimeZone.getTimeZone("EST")); String s = new StringBuilder(formatter.format(d)).toString(); return s; }
From source file:Main.java
public static String getUTCDateTimeAsStringTemp() { final SimpleDateFormat sdf = new SimpleDateFormat(DATEFORMAT); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); final String utcTime = sdf.format(new Date()); return utcTime; }
From source file:Main.java
public static String getImageName() { Date date = new Date(); SimpleDateFormat dFormat = new SimpleDateFormat("yyyy-MM-dd", new Locale("en")); dFormat.setTimeZone(TimeZone.getTimeZone("UTC")); return "Wallpaper-" + dFormat.format(date) + ".jpg"; }
From source file:Main.java
/** * Returns the current hour of the day as set on the device. * @return//from www.ja v a 2 s .co m */ public static int getHourOfDay() { SimpleDateFormat format = new SimpleDateFormat("H"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return Byte.parseByte(format.format(new Date())); }
From source file:Main.java
public static String convertCurrentTimeToGmt(String format) { final SimpleDateFormat dateFormatGmt = new SimpleDateFormat(format, Locale.getDefault()); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormatGmt.format(new Date()); }
From source file:Main.java
/** * Returns the current hour of the day as set on the device. * @return//from w w w . j a va2 s .c om */ public static int getMinuteOfDay() { SimpleDateFormat format = new SimpleDateFormat("m"); format.setTimeZone(TimeZone.getTimeZone("UTC")); return Byte.parseByte(format.format(new Date())); }
From source file:Main.java
private static String getTimestamp(String pattern) { Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat(pattern); format.setTimeZone(TimeZone.getTimeZone("GMT")); return format.format(date); }
From source file:Main.java
/** * converts time to UTC format/*from w w w . j a v a 2 s .c om*/ */ public static String getHourFormatted(Date createdUTC) { Date dateServer = createdUTC; TimeZone.setDefault(TimeZone.getTimeZone("GMT")); Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date dateGMT = cal.getTime(); return normalDateFormat(dateServer); }