进行以下更改对我来说效果很好。
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
可以使用您的语言环境,英语解决了我的问题。参考。
感谢您的回复和参考。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)