我想分别以十进制(16,4)的格式与unix时间戳分开获取日期,月份和年份,该日期是通过联系表格7写入数据库扩展Wordpress插件写入MySQL数据库的。
我需要用JAVA来做!
例如,我想解析1379446159.0400(2013-09-17 19:29:19 +00:00),但是我不知道该怎么做。
好的,谢谢大家尽管我提出的问题不够多,但仍试图为我提供帮助。
long unixSeconds = Long.valueOf(submit_time.substring(0,10)).longValue();
Date date = new Date(unixSeconds*1000L);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone("GMT-4"));
String formattedDate = sdf.format(date);
String timestampYear = formattedDate.substring(1,4);
String timestampMonth = formattedDate.substring(6,7);
String timestampDay = formattedDate.substring(9,10);
因此,我忽略了后四位数字,认为它足够合法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句