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:com.augmentum.common.util.DateUtil.java

public static DateFormat getUTCFormat(String text) {
    String pattern = StringPool.BLANK;

    if (text.length() == 8) {
        pattern = "yyyyMMdd";
    } else if (text.length() == 12) {
        pattern = "yyyyMMddHHmm";
    } else if (text.length() == 13) {
        pattern = "yyyyMMdd'T'HHmm";
    } else if (text.length() == 14) {
        pattern = "yyyyMMddHHmmss";
    } else if (text.length() == 15) {
        pattern = "yyyyMMdd'T'HHmmss";
    } else {/*from www.  ja  va2 s  .c om*/
        pattern = "yyyyMMdd'T'HHmmssz";
    }

    DateFormat dateFormat = new SimpleDateFormat(pattern);

    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    return dateFormat;
}

From source file:com.indoqa.lang.util.TimeUtils.java

public static String formatSolrDate(Date date) {
    DateFormat dateFormat = new SimpleDateFormat(SOLR_DATE_FORMAT);
    dateFormat.setTimeZone(TIME_ZONE);
    return dateFormat.format(date);
}

From source file:com.indoqa.lang.util.TimeUtils.java

public static Date parseSolrDate(String date) throws ParseException {
    DateFormat dateFormat = new SimpleDateFormat(SOLR_DATE_FORMAT);
    dateFormat.setTimeZone(TIME_ZONE);
    return dateFormat.parse(date);
}

From source file:com.wavemaker.runtime.FileController.java

public static DateFormat htmlExpiresDateFormat() {
    DateFormat httpDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
    httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return httpDateFormat;
}

From source file:helper.util.DateHelper.java

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

From source file:com.fluidops.iwb.widget.TimelineWidget.java

private static Date parseDate(String dateOriginalFormat) {
    Date date = null;/*from  w  ww . ja va2 s  .c  o m*/

    // Loop over supported date formats
    for (DateFormat formatter : formatters) {
        try {
            formatter.setTimeZone(TimeZone.getTimeZone("GMT-0"));
            date = (Date) formatter.parse(dateOriginalFormat);
            break;
        }
        // If date format is not supported..
        catch (ParseException e) {
            //ignore, try next formatter
        }
    }
    if (date == null) {
        logger.error("Date format not supported: " + dateOriginalFormat + ". Using today instead.");
        date = new Date();
    }
    return date;
}

From source file:helper.util.DateHelper.java

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

From source file:com.adobe.acs.commons.version.impl.EvolutionConfig.java

public static String printObject(Object obj) {
    if (obj == null) {
        return "";
    }/*from  ww w  . j a va  2  s. c om*/
    if (obj instanceof String) {
        return (String) obj;
    } else if (obj instanceof String[]) {
        String[] values = (String[]) obj;
        StringBuilder result = new StringBuilder();
        result.append("[");
        for (int i = 0; i < values.length; i++) {
            result.append(values[i]);
            if (i != (values.length - 1)) {
                result.append(", ");
            }
        }
        result.append("]");
        return result.toString();
    } else if (obj instanceof Calendar) {
        Calendar value = (Calendar) obj;
        DateFormat dateFormat = DateFormat.getDateTimeInstance();
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        return dateFormat.format(value.getTime());
    } else {
        return obj.toString();
    }
}

From source file:org.apache.falcon.util.DateUtil.java

private static DateFormat getSpecificDateFormat(String format) {
    DateFormat dateFormat = new SimpleDateFormat(format);
    dateFormat.setTimeZone(activeTimeZone);
    return dateFormat;
}

From source file:helper.util.DateHelper.java

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