private static DateFormatSymbols getCachedInstance ( Locale locale ) { SoftReference < DateFormatSymbols > ref = cachedInstances . get ( locale ) ; DateFormatSymbols dfs = null ; if ( ref == null || ( dfs = ref . get ( ) ) == null ) { dfs = new DateFormatSymbols ( locale ) ; ref = new SoftReference < DateFormatSymbols > ( dfs ) ; SoftReference < DateFormatSymbols > x = cachedInstances . putIfAbsent ( locale , ref ) ; if ( x != null ) { DateFormatSymbols y = x . get ( ) ; if ( y != null ) { dfs = y ; } else { // Replace the empty SoftReference with ref. cachedInstances . put ( locale , ref ) ; } } } return dfs ; }
Returns a cached DateFormatSymbols if it s found in the cache . Otherwise this method returns a newly cached instance for the given locale .