我有 int
数字 2455449,我知道它代表日期 09/09/2010。如何定义使用的日期格式?我需要以这种格式生成一个新日期。它将用于 http 请求。我想那是朱利安,但我不确定。我尝试将此数字转换为日期,但它没有返回正确的日期 09/09/2010。可能我使用了错误的 SimpleDateFormat("mm/dd/yy")
或 Calendar.XXXX(例如Calendar.DAY_OF_YEAR
)
最佳答案
var now = new Date();
now.format("m/dd/yy");
// Returns, e.g., 6/09/07
// Can also be used as a standalone function
dateFormat(now, "dddd, mmmm dS, yyyy, h:MM:ss TT");
// Saturday, June 9th, 2007, 5:46:21 PM
// You can use one of several named masks
now.format("isoDateTime");
// 2007-06-09T17:46:21
// ...Or add your own
dateFormat.masks.hammerTime = 'HH:MM! "Can\'t touch this!"';
now.format("hammerTime");
// 17:46! Can't touch this!
关于java - 如何定义日期格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3990255/