开发者

Convert sql timestamp to yyyy-mm-ddThh:mm:ss.sssZ

开发者 https://www.devze.com 2023-04-10 22:03 出处:网络
I need to convert a SQL Server timestamp format (stored on Timestamp java data type) into this format yyyy-mm-ddThh:mm:ss.sssZ (it\'s the d开发者_如何转开发ate format parsed by Alfresco)

I need to convert a SQL Server timestamp format (stored on Timestamp java data type) into this format yyyy-mm-ddThh:mm:ss.sssZ (it's the d开发者_如何转开发ate format parsed by Alfresco)

How can I do it?

thanks for your time!

Andrea


Try this SimpleDateFormat:

SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
String yourformattedDate = sdf.format(yourDate);


You could try and get the time (in ms) from your TimeStamp instance, create a Date instance and use the DateFormatter class to format it anyway you want. That is, assuming DateFormatter supports the format you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消