线程安全的时间类
来源:互联网 发布:淘宝开服装店教程 编辑:程序博客网 时间:2024/05/21 09:04
import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;/** * @Description: 线程安全的时间类* @author :* @date :2017年5月23日 下午4:50:55 */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); } }
阅读全文
0 0
- 线程安全的时间类
- 线程安全的类
- 线程安全的类
- 时间转换封装 线程安全
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- linux中关于时间函数的线程安全
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 关于SimpleDateFormat安全的时间格式化线程安全问题
- 线程安全的单间类
- 设计线程安全的类
- 线程安全类的设计
- 全程尬聊之阿里2017实习生面试
- 人机大战|深度拆解AlphaGo套路
- Tensorflow 学习笔记之 共享变量(Sharing Variables)
- opengl opengles 版本对应的时间
- 程序猿学习第七天,超链接样式和div
- 线程安全的时间类
- 字符串排列-dfs算法
- WIFI模块ESP8266的使用指南(客户端和服务器两种模式建立)
- Nginx搭建反向代理服务器过程详解
- 网页存储Web Storage
- leetcode 7. Reverse Integer
- 数字签名
- eclipse中svn插件的安装与使用
- 店铺突然被淘宝给永久封号, 恨死淘宝霸王恨死马云!!