简体   繁体   English

将sql时间戳转换为yyyy-mm-ddThh:mm:ss.sssZ

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

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 date format parsed by Alfresco) 我需要将SQL Server时间戳格式(存储在Timestamp java数据类型上)转换为此格式yyyy-mm-ddThh:mm:ss.sssZ(这是Alfresco解析的日期格式)

How can I do it? 我该怎么做?

thanks for your time! 谢谢你的时间!

Andrea 安德里亚

Try this SimpleDateFormat: 试试这个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. 您可以尝试从TimeStamp实例获取时间(以毫秒为单位),创建一个Date实例,并使用DateFormatter类随意设置其格式。 That is, assuming DateFormatter supports the format you want. 也就是说,假设DateFormatter支持所需的格式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 了解具体的UTC时间格式YYYY-MM-DDTHH:MM:SS.SSSZ - Understanding specific UTC time format YYYY-MM-DDTHH:MM:SS.SSSZ ISO 8601 DateTimeFormatter 截断此格式的毫秒:'YYYY-MM-DDTHH:mm:ss.sssZ' - ISO 8601 DateTimeFormatter truncates the ms of this format:'YYYY-MM-DDTHH:mm:ss.sssZ' 如何将时间戳从yyyy-MM-ddThh:mm:ss:SSSZ格式转换为MM / dd / yyyy hh:mm:ss.SSS格式?从ISO8601到UTC - How can I convert a timestamp from yyyy-MM-ddThh:mm:ss:SSSZ format to MM/dd/yyyy hh:mm:ss.SSS format? From ISO8601 to UTC 如何解析格式 yyyy-MM-ddTHH:mm:ss.SSS+ZZZZ 的 UTC 时间戳 - How to parse UTC timestamp of format yyyy-MM-ddTHH:mm:ss.SSS+ZZZZ YYYY-MM-DDThh:mm:ss在Java中老化的字符串 - YYYY-MM-DDThh:mm:ss string to age in java 无法理解“ YYYY-MM-DDTHH:MM:SS”日期格式 - Not able to understand “YYYY-MM-DDTHH:MM:SS” date format 尝试在Android中将yyyy-MM-ddTHH:mm:ss-07:00转换为正确的时间 - Trying to convert yyyy-MM-ddTHH:mm:ss-07:00 to correct time in Android 为什么“-190732550-MM-ddTHH:mm:ss.SSSZ”日期时间不会解析失败 - Why "-190732550-MM-ddTHH:mm:ss.SSSZ" datetime does not fail to parse 我们如何在 Java 中将 yyyy-MM-dd-HH.mm.ss.SSSSSS 转换为 yyyy-MM-dd'T'HH:mm:ss.SSSz? - How we can convert yyyy-MM-dd-HH.mm.ss.SSSSSS to yyyy-MM-dd'T'HH:mm:ss.SSSz in Java? Java 格式 yyyy-MM-dd'T'HH:mm:ss.SSSz 到 yyyy-mm-dd HH:mm:ss - Java format yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM