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 | 0 | public class DateFormatThread { |
9 | |
|
10 | 0 | private static ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>() { |
11 | |
|
12 | |
protected DateFormat initialValue() { |
13 | 0 | return new SimpleDateFormat("yyyy-MM-dd"); |
14 | |
} |
15 | |
|
16 | |
}; |
17 | |
|
18 | |
public static Date parse(String source) throws ParseException { |
19 | 0 | Date d = df.get().parse(source); |
20 | 0 | return d; |
21 | |
} |
22 | |
|
23 | |
public static String format(Date date) { |
24 | 0 | return df.get().format(date); |
25 | |
} |
26 | |
|
27 | |
} |