SimpleDateFormat sdf = new SimpleDateFormat("yyyy/M/dd hh:mm",java.util.Locale.CHINA);
Date date = sdf.parse("2011/4/21 21:31");我想让date的值为2011/4/21 21:31
date的值却是Thu Apr 21 21:31:00 GMT+00:00 2011Date date = new Date("2011/4/21 21:31");
date的值还是Thu Apr 21 21:31:00 GMT+00:00 2011我要怎么才能将Date的值设为2011/4/21 21:31呢?谢谢大家了!
Date date = sdf.parse("2011/4/21 21:31");我想让date的值为2011/4/21 21:31
date的值却是Thu Apr 21 21:31:00 GMT+00:00 2011Date date = new Date("2011/4/21 21:31");
date的值还是Thu Apr 21 21:31:00 GMT+00:00 2011我要怎么才能将Date的值设为2011/4/21 21:31呢?谢谢大家了!
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd hh:mm");
final Calendar mCalendar = Calendar.getInstance();
final Date mDate = mCalendar.getTime();
final String date = sdf.format(mDate);
System.out.println(sdf.format(mDate));
这样打印的是 2011/04/21 03:43 可是date的值实际上是 Thu Apr 21 15:43:06 GMT+00:00 2011
我是想让date的值为2011/04/21 03:43
Date curDate = new Date(System.currentTimeMillis());
String str = formatter.format(curDate);
date的数据就是那个样子的,不管怎么改,只是输出形式不同,实际数据结构不会变化。
换成String吧,就是你要的结果了