当前位置: 技术问答>java相关
请问定义了Calendar 怎么得不到当前的日期呢???谢谢
来源: 互联网 发布时间:2015-09-15
本文导语: Calendar c=Calendar.getInstance(); System.out.println(c.YEAR); System.out.println(c.MONDAY); System.out.println(c.DATE); 打出来的是: 1 2 5 什么意思?? 想显示 2002 9 25 怎么做呢?? | String text = "2001...
Calendar c=Calendar.getInstance();
System.out.println(c.YEAR);
System.out.println(c.MONDAY);
System.out.println(c.DATE);
打出来的是:
1
2
5
什么意思??
想显示
2002
9
25 怎么做呢??
System.out.println(c.YEAR);
System.out.println(c.MONDAY);
System.out.println(c.DATE);
打出来的是:
1
2
5
什么意思??
想显示
2002
9
25 怎么做呢??
|
String text = "20010101";
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
ParsePosition pos = new ParsePosition(0);
Date value = formatter.parse(text, pos);
//value.setDate(value.getDate() - 1);
java.util.Calendar c = java.util.Calendar.getInstance();
//c.setTime(value);
for (int i = 0; i
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
ParsePosition pos = new ParsePosition(0);
Date value = formatter.parse(text, pos);
//value.setDate(value.getDate() - 1);
java.util.Calendar c = java.util.Calendar.getInstance();
//c.setTime(value);
for (int i = 0; i