我要获得的是
2006-03-01
2006-03-02
2006-03-03
2006-03-04
一连串不带 时 分 秒 的干净日期.
最简单的方法是
int year = 2006;
int month = 3;
int day = 1
Date reportDate = new Date(year, month, day);
Date d0301 = reportDate;
day++;
reportDate.setDate(day);
Date d0302 = reportDate;而现在new Date 和 setDate被替代, 请问如何使用 Calendar 类的方法来获得我所要的 YYYY-MM-DD 格式的数据.
2006-03-01
2006-03-02
2006-03-03
2006-03-04
一连串不带 时 分 秒 的干净日期.
最简单的方法是
int year = 2006;
int month = 3;
int day = 1
Date reportDate = new Date(year, month, day);
Date d0301 = reportDate;
day++;
reportDate.setDate(day);
Date d0302 = reportDate;而现在new Date 和 setDate被替代, 请问如何使用 Calendar 类的方法来获得我所要的 YYYY-MM-DD 格式的数据.
date = f.format(date);
date即是
String s = f.format(new Date());
import java.text.*;
public class TimeSet { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SimpleDateFormat f = new SimpleDateFormat("yyyy-mm-dd");
//Date d=new Date(2006,3,15);
Calendar ca=Calendar.getInstance();
int year=2006;
int month=10;
int day=15;
ca.set(ca.YEAR,year);
ca.set(ca.MONTH,month);
ca.set(ca.DATE,day);
System.out.println(f.format(ca.getTime()));
ca.add(ca.DATE,1);
System.out.println(f.format(ca.getTime()));
}}
你该从数据库下手啊。有系统函数给你用你不充分利用。。