Android上的时间解析问题

Android上的时间解析问题,第1张

Android上的时间解析问题

进行以下更改对我来说效果很好。

 public static long convertdatetotimestamp(String datestring, String newdateformat, String olddateformat){        DateFormat originalFormat = new SimpleDateFormat(olddateformat,Locale.ENGLISH);        DateFormat targetFormat = new     SimpleDateFormat(newdateformat,Locale.ENGLISH);        Date date = null;        try { date = originalFormat.parse(datestring.replaceAll("\.", "")); String formattedDate = targetFormat.format(date); Date parsedDate = targetFormat.parse(formattedDate); long nowMilliseconds = parsedDate.getTime(); return nowMilliseconds;        } catch (ParseException e) { e.printStackTrace(); return 0;        }    }

Locale.ENGLISH
可以使用您的语言环境,英语解决了我的问题。参考。

感谢您的回复和参考



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5587368.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存