View Javadoc

1   package org.kuali.student.common.util;
2   
3   import java.text.DateFormat;
4   import java.text.ParseException;
5   import java.text.SimpleDateFormat;
6   import java.util.Date;
7   
8   public class DateFormatThread {
9   
10  	private static ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>() {
11  
12  		protected DateFormat initialValue() {
13  			return new SimpleDateFormat("yyyy-MM-dd");
14  		}
15  
16  	};
17  
18  	public static Date parse(String source) throws ParseException {
19  		Date d = df.get().parse(source);
20  		return d;
21  	}
22  
23  	public static String format(Date date) {
24  		return df.get().format(date);
25  	}
26  
27  }