???????Java??SimpleDateFormat????????????
???????????? ???????[ 2013/6/13 10:41:46 ] ????????
???????????д????
package com.peidasoft.dateformat;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class ThreadLocalDateUtil {
private static final String date_format = "yyyy-MM-dd HH:mm:ss";
private static ThreadLocal<DateFormat> threadLocal = new ThreadLocal<DateFormat>();
public static DateFormat getDateFormat()
{
DateFormat df = threadLocal.get();
if(df==null){
df = new SimpleDateFormat(date_format);
threadLocal.set(df);
}
return df;
}
public static String formatDate(Date date) throws ParseException {
return getDateFormat().format(date);
}
public static Date parse(String strDate) throws ParseException {
return getDateFormat().parse(strDate);
}
}
????????????ThreadLocal?? ?????????????????????????????????????????????????????????????????????????????????????????£???????????????????
????4??????JDK?????????????е??????????
????1?????Apache commons ???FastDateFormat???????????????????SimpleDateFormat?? ????????????????format?? ?????????????н?????
????2?????Joda-Time???????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????÷?????????????????????????????????????????????????????????÷?????????ThreadLocal?????檔
????Joda-Time??????????????????????????á?
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11