import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class CTime
{
private String strTime;
public CTime(String strTime)
{
this.strTime = strTime;
}
public void printNextTime()
{
Calendar cal = Calendar.getInstance();
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try
{
date = sdf.parse(this.strTime);
cal.setTime(date);
cal.add(cal.DATE, 1);
System.out.println("下一天的时间是:" + sdf.format(cal.getTime()));
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args)
{
CTime time = new CTime("2005-12-31");
time.printNextTime();
}
}
Java得到下一天明天,明天时间
最新推荐文章于 2022-09-28 15:58:12 发布