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:helper.util.DateHelper.java

public static DateFormat getDateFormatYyyyMmDdHhMm(TimeZone timeZone) {
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_YYYY_MM_DD_HH_MM_MASK);
    dateFormat.setTimeZone(timeZone);
    return dateFormat;
}

From source file:helper.util.DateHelper.java

public static DateFormat getDateFormatDayOfWeekDayOfMonthYearAmTz(TimeZone timeZone) {
    DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_DOW_MON_YY_AM_PM_TZ_MASK);
    dateFormat.setTimeZone(timeZone);
    return dateFormat;
}

From source file:de.odysseus.calyxo.base.util.ParseUtils.java

private static Date parseDate(String value) throws ParseException {
        DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT, locale);
        format.setTimeZone(TimeZone.getTimeZone("GMT"));
        return (Date) parse(format, value);
    }/*  w w  w .  j av  a2  s.  c  om*/

From source file:com.murrayc.murraycgwtpexample.server.ThingServiceImpl.java

private static String getCurrentTime() {
    //TODO: Performance:
    final TimeZone tz = TimeZone.getTimeZone("UTC");
    final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");
    df.setTimeZone(tz);
    return df.format(new Date());
}

From source file:com.gallatinsystems.common.util.S3Util.java

private static String getDate() {
    final DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ", Locale.US);
    df.setTimeZone(TimeZone.getTimeZone("GMT"));
    return df.format(new Date()) + "GMT";
}

From source file:com.projity.util.DateTime.java

public static DateFormat utcShortDateFormatInstance() {
    DateFormat f = DateFormat.getDateInstance(DateFormat.SHORT);
    f.setTimeZone(DateUtils.UTC_TIME_ZONE);
    return f;/*from w  w  w  .  ja v a 2  s .  co  m*/
}

From source file:com.vmware.identity.wstrust.client.impl.RequestBuilderHelper.java

/**
 * Creates a datetime formatter needed for populating objects containing XML
 * requests/responses./*from  w w w  . j  a  v a2 s .  com*/
 */
private static DateFormat createDateFormatter() {
    DateFormat dateFormat = new SimpleDateFormat(XML_DATE_FORMAT);

    // always send UTC/GMT time
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));

    return dateFormat;
}

From source file:pack.test.SignedRequestsHelper.java

/**
 * Generate a ISO-8601 format timestamp as required by Amazon.
 *  //from w w  w. ja  va  2 s. c  o m
 * @return  ISO-8601 format timestamp.
 */
public static String timestamp() {
    String timestamp = null;
    Calendar cal = Calendar.getInstance();
    DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    dfm.setTimeZone(TimeZone.getTimeZone("GMT"));
    timestamp = dfm.format(cal.getTime());
    return timestamp;
}

From source file:eu.e43.impeller.Utils.java

public static long parseDate(String date) {
    if (date == null)
        return new Date().getTime();

    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
    df.setTimeZone(TimeZone.getTimeZone("Zulu"));
    try {/*  w  ww .  j  a va 2 s  .c  o  m*/
        return df.parse(date).getTime();
    } catch (ParseException e) {
        return new Date().getTime();
    }
}

From source file:net.nosleep.superanalyzer.util.Misc.java

public static Date parseXmlDate(String xml) {
    Date date = null;/*from w  w  w  .  j a v  a2 s . c o  m*/

    try {
        // DateFormat format = new
        // SimpleDateFormat("yyyy-MM-ddTHH:mm:ss -0000");
        java.text.DateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        // explicitly set timezone of input if needed
        df.setTimeZone(java.util.TimeZone.getTimeZone("Zulu"));
        date = df.parse(xml);

        // date = format.parse(xml);
    } catch (ParseException e) {
        System.out.println("Failed to parse xml date: " + xml);
    }
    return date;
}