Here you can find the source of getPooledSDF(String format)
Gets a SimpleDateFormat for the given format.
Parameter | Description |
---|---|
format | The format |
protected static SimpleDateFormat getPooledSDF(String format)
//package com.java2s; // in accordance with the terms of the license agreement accompanying it. import java.text.SimpleDateFormat; import java.util.EmptyStackException; import java.util.Hashtable; import java.util.Stack; public class Main { protected static Hashtable sdfCache = new Hashtable(); /**// w w w .ja v a 2 s.c o m * <p>Gets a SimpleDateFormat for the given format. SimpleDateFormat objects * are cached for performance and locking reasons * @param format The format * @return The SimpleDateFormat object */ protected static SimpleDateFormat getPooledSDF(String format) { SimpleDateFormat sdf = null; Stack stack = (Stack) sdfCache.get(format); if (stack != null) { try { sdf = (SimpleDateFormat) stack.pop(); } catch (EmptyStackException ese) { // Ignore - create below } } // Either this is the first time we've requested this format or all // of the objects are being used; create a new one if (sdf == null) { sdf = new SimpleDateFormat(format); } return sdf; } }