Java Date GMT Format getThreadLocalGMTDateFormat(final String format)

Here you can find the source of getThreadLocalGMTDateFormat(final String format)

Description

get Thread Local GMT Date Format

License

Apache License

Declaration

public static ThreadLocal<SimpleDateFormat> getThreadLocalGMTDateFormat(final String format) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.SimpleTimeZone;

public class Main {
    public static ThreadLocal<SimpleDateFormat> getThreadLocalGMTDateFormat(final String format) {
        return new ThreadLocal<SimpleDateFormat>() {
            @Override//ww w .j  a  va  2  s  . c  o  m
            protected SimpleDateFormat initialValue() {
                return getGMTDateFormat(format);
            }
        };
    }

    public static SimpleDateFormat getGMTDateFormat(String strFormat) {
        SimpleDateFormat format = new SimpleDateFormat(strFormat);
        format.setCalendar(getGMTCalendar());
        return format;
    }

    public static Calendar getGMTCalendar() {
        return Calendar.getInstance(new SimpleTimeZone(0, "GMT"));
    }
}

Related

  1. formatGMTDate(Date gmtTime, int offset)
  2. getDefaultID2GMT()
  3. getFormattedGMTDate(long timestamp)
  4. getNewGmtSimpleDateFormat(String format)
  5. getStringBaseGMT(Date date, String timezone)
  6. getTimeAndDateAtGMT()
  7. getTzToGmt(String dateStr, String dateFormat, String beforeTimeZone, String afterTimeZone)
  8. parseDate(String gmtTimeString)
  9. parseGMT(String gmtTime)