List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:Main.java
public static long dateToMilli(String dateString) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setTimeZone(TimeZone.getDefault()); try {/*from ww w . j a va 2 s . c o m*/ return sdf.parse(dateString).getTime(); } catch (ParseException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static String getCurrentUtcTime() { Date l_datetime = new Date(); DateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); TimeZone l_timezone = TimeZone.getDefault(); formatter.setTimeZone(l_timezone);// w w w .j av a 2s . c o m String l_utc_date = formatter.format(l_datetime); return l_utc_date; }
From source file:Main.java
public static SimpleDateFormat getStartDateTimeInTimezone(String timezone) { SimpleDateFormat format = new SimpleDateFormat("EEEE, MMMM d, h:mm a"); if (timezone == null || timezone.isEmpty()) { format.setTimeZone(TimeZone.getDefault()); } else/*from w ww . j av a 2 s . c o m*/ format.setTimeZone(TimeZone.getTimeZone("GMT+" + timezone)); return format; }
From source file:Main.java
public static SimpleDateFormat getServerDateTimeInTimezone(String timezone) { SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy"); if (timezone == null || timezone.isEmpty()) { format.setTimeZone(TimeZone.getDefault()); } else {/* w w w. j a v a 2 s. c om*/ format.setTimeZone(TimeZone.getTimeZone("GMT+" + timezone)); } return format; }
From source file:Main.java
public static String formatTimestamp(long timestamp) { DateFormat dtf = new SimpleDateFormat("HH:mm:ss"); dtf.setTimeZone(TimeZone.getDefault()); return dtf.format(new Date(timestamp)); }
From source file:Main.java
public static Date getTimeCurrent() { Calendar cal = Calendar.getInstance(); Date timeNow = new Date(); cal.setTime(timeNow);//w w w . j a v a2s . c om // Um numero negativo vai decrementar a data cal.add(Calendar.MILLISECOND, TimeZone.getDefault().getOffset(timeNow.getTime()) * -1); return cal.getTime(); }
From source file:Main.java
/** * Return the {@link TimeZone} the app is set to use (either user or conference). * * @param context Context to be used to lookup the {@link android.content.SharedPreferences}. *//*from ww w. j a v a 2 s . c o m*/ public static TimeZone getDisplayTimeZone(Context context) { return TimeZone.getDefault(); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") static String setDate() { // add DateTime to filename Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); date.setTimeZone(TimeZone.getDefault()); _currentDate = date.format(currentLocalTime); return _currentDate; }
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String getTimeStringWithGMT(Date date) { SimpleDateFormat dateformat = new SimpleDateFormat("yyyy.MM.dd. aa hh:mm (ZZZZ)"); dateformat.setTimeZone(TimeZone.getDefault()); return dateformat.format(date); }
From source file:Main.java
@SuppressLint("SimpleDateFormat") static String setDateTime() { // add DateTime to filename Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Date currentLocalTime = cal.getTime(); SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); date.setTimeZone(TimeZone.getDefault()); _currentDateTime = date.format(currentLocalTime); return _currentDateTime; }