泉州网站制作设计,网站开发人员结构配比,步骤的英文单词,民用网络架构Mon Oct 16 09:51:28 2023
这是linux 的 date命令得到的时间#xff0c;要转换称时间戳。 EEE MMM dd HH:mm:ss yyyy
这样的格式#xff0c;看起来就是正确的#xff0c;可是就是报错
Unparseable date: Mon Oct 16 09:51:28 2023
下面是正确的代码 String[…Mon Oct 16 09:51:28 2023
这是linux 的 date命令得到的时间要转换称时间戳。 EEE MMM dd HH:mm:ss yyyy
这样的格式看起来就是正确的可是就是报错
Unparseable date: Mon Oct 16 09:51:28 2023
下面是正确的代码 String[] fmts new String[] {EEE MMM dd HH:mm:ss yyyy, EEE, MMM d, yy};String[] vs new String[] { Mon Oct 16 09:51:28 2023, Wed, Jul 4, 01};for(int i0; ifmts.length; i) {try {SimpleDateFormat dateFormat new SimpleDateFormat(fmts[i], Locale.ENGLISH);//Date date dateFormat.parse(vs[i]);str (date.getTime() / 1000) ;System.out.println([OK] str vs[i] , fmtfmts[i] -- date.getTime()dateFormat.format(date));} catch (Exception e) {CommonUtils.logError(e, str vs[i] , fmtfmts[i] -\n);}} Locale.ENGLISH 这个是关键。
但是 用 Locale.CHINESE 也不能认识 “星期三”