Example usage for java.text DateFormat setTimeZone

List of usage examples for java.text DateFormat setTimeZone

Introduction

In this page you can find the example usage for java.text DateFormat setTimeZone.

Prototype

public void setTimeZone(TimeZone zone) 

Source Link

Document

Sets the time zone for the calendar of this DateFormat object.

Usage

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 final static String now() {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    df.setTimeZone(tz);
    return df.format(new Date());
}

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  ava2s  .co m*/
}

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);

    return df.format(date);
}

From source file:Main.java

public static String timestamp() {
    String timestamp = null;//from   w  w  w .j av  a  2s  .  c  o  m
    Calendar cal = Calendar.getInstance();
    DateFormat dfm = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss", Locale.US);
    dfm.setTimeZone(TimeZone.getTimeZone("GMT"));
    timestamp = dfm.format(cal.getTime());
    return timestamp;
}

From source file:Main.java

public static DateFormat createLocalDateFormat() {
    DateFormat df = new SimpleDateFormat(localDateTimeFormatString);
    df.setTimeZone(TimeZone.getTimeZone("UTC"));
    return df;/*w  ww.  j  a v a 2 s .  c om*/
}

From source file:Main.java

public static String TimeToString(Date d) {
    DateFormat formatter;

    formatter = new SimpleDateFormat("HH-mm");
    formatter.setTimeZone(TimeZone.getTimeZone("EST"));

    String s = new StringBuilder(formatter.format(d)).toString();
    return s;//from  ww w .  j a  v  a  2 s  . co  m
}

From source file:com.jaspersoft.jasperserver.war.cascade.handlers.converters.TimestampDataConverter.java

public static DateFormat getDateFormatWithTimeZone(DateFormat dateFormat) {
    dateFormat.setTimeZone(TimeZoneContextHolder.getTimeZone());
    return dateFormat;
}

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);
}