请注意使用java.text.DateFormat   Leave a comment

在使用:java.text.DateFormat类时,请注意他的format(),parse()等方法不是线程安全的,一定不要把此变量定义成全局的静态变量,否在在多线程的并发环境里会发生你意想不到的错误!!!

 例如,不要定义成一下样子:

  1. public static final SimpleDateFormat timestampFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);  

 一定要把:java.text.DateFormat作为局部变量来使用.

Posted 2009年11月9日 by gw8310 in date, java

Tagged with , ,

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: