我这里有一个java.sql.Timestamp类型的变量,希望得到他的下一个月的时间,
例如:
Timestamp timestamp = new Timestamp.valueOf("06-05-01 00:00:00.000000");
我想得到
06-06-01 00:00:00.000000
有什么好的方法么。我现在的方法是
SimpleDateFormat sdf = new SimpleDateFormat("MM");
String month = sdf.format(timestamp);
然后再作成Timestamp类型。其实我是想得到这种类型的东西,
从Timestamp timestamp = new Timestamp.valueOf("06-05-01 00:00:00.000000");
得到年月
200605
然后得到
200604
200606
200607
200608有什么意见,请留下,谢谢
例如:
Timestamp timestamp = new Timestamp.valueOf("06-05-01 00:00:00.000000");
我想得到
06-06-01 00:00:00.000000
有什么好的方法么。我现在的方法是
SimpleDateFormat sdf = new SimpleDateFormat("MM");
String month = sdf.format(timestamp);
然后再作成Timestamp类型。其实我是想得到这种类型的东西,
从Timestamp timestamp = new Timestamp.valueOf("06-05-01 00:00:00.000000");
得到年月
200605
然后得到
200604
200606
200607
200608有什么意见,请留下,谢谢
Calendar c = Calendar.getInstance();
c.setTimeInMillis(ts.getTime());
for (int i=0;i<3;i++){
c.add(Calendar.MONTH,1);
Timestamp ts1 = new Timestamp(c.getTimeInMillis());
System.out.println(ts1);
}
hi.baidu.com/yliang 看看
Calendar cal = Calendar.getInstance();
cal.setTime(timestamp);
cal.add(Calendar.MONTH,1);
timestamp = new Timestamp(cal.getTime().getTime());
System.out.println(new SimpleDateFormat("yy-MM-dd HH:mm:ss.SSSSSS").format(timestamp));