Here you can find the source of buildDateFormat(final String pattern)
Parameter | Description |
---|---|
pattern | date format pattern. |
private static SimpleDateFormat buildDateFormat(final String pattern)
//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; } }