Java String to date 问题

SuperBoo 2009-12-30 01:33:38
代码如下

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleTime {
public static void main(String[] args) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
try {
Date currentTime = format.parse("2009-09-12 13:04:54");

System.out.println(currentTime);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



为什么 不论我 给写 几月 出来都是1月? 其他都对
...全文
84 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jungle1171 2009-12-30
  • 打赏
  • 举报
回复
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Nature_2009 2009-12-30
  • 打赏
  • 举报
回复

SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");


替换成


SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
meadking 2009-12-30
  • 打赏
  • 举报
回复
奇怪...呵呵
debug一下..
SuperBoo 2009-12-30
  • 打赏
  • 举报
回复
结贴给分
SuperBoo 2009-12-30
  • 打赏
  • 举报
回复
我看看去
wangzhouyu 2009-12-30
  • 打赏
  • 举报
回复
yyyy-mm-dd中的mm应该大写MM

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧