Java Date Create buildDateFormat(final String pattern)

Here you can find the source of buildDateFormat(final String pattern)

Description

Get a SimpleDateFormat object by given pattern.

License

Apache License

Parameter

Parameter Description
pattern date format pattern.

Return

a SimpleDateFormat object by given pattern.

Declaration

private static SimpleDateFormat buildDateFormat(final String pattern) 

Method Source Code

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

import java.text.SimpleDateFormat;

public class Main {
    private static final ThreadLocal<SimpleDateFormat> simpleDateFormatCache = new ThreadLocal<SimpleDateFormat>();

    /**/*www.  j ava2  s .co  m*/
     * Get a SimpleDateFormat object by given pattern.
     * 
     * @param pattern date format pattern.
     * @return a SimpleDateFormat object by given pattern.
     */
    private static SimpleDateFormat buildDateFormat(final String pattern) {

        SimpleDateFormat simpleDateFormat = simpleDateFormatCache.get();
        if (simpleDateFormat == null) {
            simpleDateFormat = new SimpleDateFormat();
            simpleDateFormatCache.set(simpleDateFormat);
        }
        simpleDateFormat.applyPattern(pattern);
        return simpleDateFormat;
    }
}

Related

  1. add24HtoDate(Date date)
  2. addTimeToDate(Date date, Date time)
  3. buildDate(int y, int m, int d)
  4. buildDate(String dateAsString)
  5. buildDatetime(Date datePart, Date hourMinutePart)
  6. buildDateTime(String curDate, String curTime, String meridiem)
  7. buildDateTimeUTC(Calendar cal)
  8. castToDate(Object value)