解析Java字符串到目前为止 [英] Parsing Java String to date
本文介绍了解析Java字符串到目前为止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
日志(2个不同的日期):
log(2 different dates):
START TIME BEFORE PARSE: 06/27/2012 09:00
START TIME AFTER PARSE : Thu Mar 06 09:00:00 EET 2014
START TIME BEFORE PARSE: 07/06/2012 09:00
START TIME AFTER PARSE : Thu Jun 07 09:00:00 EEST 2012
代码:
DateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
Date date = sdf.parse(time);
System.out.println("TIME BEFORE PARSE: " + time);
System.out.println("TIME AFTER PARSE : " + date);
为什么今年会混乱?如何让它工作?
Why does it mess up the year? How to get it to work?
推荐答案
因为你用这个日期倒转了这个月:
Because you inverted the month with the date:
dd/MM/yyyy HH:mm
06/27/2012 09:00
一年没有27个月。
这篇关于解析Java字符串到目前为止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文