01: /*
02: * @(#)DateFormatCache.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lib;
10:
11: import pnuts.lang.Context;
12: import java.util.Date;
13: import java.util.Calendar;
14: import java.text.DateFormat;
15: import java.text.SimpleDateFormat;
16:
17: class DateFormatCache extends ResourceCache {
18: private final static boolean DEBUG = false;
19:
20: Context context;
21:
22: DateFormatCache(Context context) {
23: this .context = context;
24: }
25:
26: protected Object createResource(Object pattern) {
27: if (DEBUG) {
28: System.out.println("createResorce " + pattern);
29: }
30: DateFormat df = new SimpleDateFormat((String) pattern, locale
31: .getLocale(context));
32: df.setTimeZone(date.getTimeZone(context));
33: return df;
34: }
35:
36: DateFormat get(String pattern) {
37: return (DateFormat) super.getResource(pattern);
38: }
39: }
|