当前位置: 代码迷 >> Web前端 >> JAVA准时间段查询时String型结束时间增加加一天
  详细解决方案

JAVA准时间段查询时String型结束时间增加加一天

热度:466   发布时间:2013-01-26 13:47:02.0
JAVA按时间段查询时String型结束时间增加加一天
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class test3 {
public static void main(String[] args) {
String d = "2004-1-1";
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date dd;
try {
dd = format.parse(d);
Calendar calendar = Calendar.getInstance();
calendar.setTime(dd);
calendar.add(Calendar.DAY_OF_MONTH, 1);
System.out.println(format.format(calendar.getTime()));
} catch (ParseException e) {
e.printStackTrace();
}
}
}
  相关解决方案