我有以下日期:
2011-10-07T08:51:52.006Z
现在我想将其解析为 GregorianCalendar。有没有比使用子字符串并将它们解析为整数更简单的方法?
时间字符串中的 Z 是什么?
我尝试使用 SimpleDateFormat 解析它,但我找不到日期字符串中 T 的解释。
最佳答案
DateFormat format = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" )
Date date = format.parse( "2011-10-07T08:51:52.006Z" );
Calendar calendar = new GregorianCalendar();
calendar.setTime( date );
关于java - 将字符串格式的日期解析为 GregorianCalendar 的最简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8282701/