import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Test {
public static void main(String[] args) throws Throwable {
Test test = new Test();
System.out.println(test.getStartDay());
TP-LINK WR340G设置教程 System.out.println(test.getDefaultDay());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.format(test.getStartDay()));
System.out.println(sdf.format(test.getDefaultDay()));
System.out.println(test.getStartDay().before(test.getDefaultDay()));
System.out.println(test.getStartDay().after(test.getDefaultDay()));
}
public Date getStartDay() throws Throwable {
String str = "2011-12-2";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar lastDate = Calendar.getInstance();
lastDate.setTime(sdf.parse(str));
return sdf.parse(str);
}
public Date getDefaultDay() throws Throwable {
String str = "2011-12-2";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar lastDate = Calendar.getInstance();
lastDate.setTime(sdf.parse(str));
lastDate.set(Calendar.DATE, 1);// 设为当前月的1 号
lastDate.add(Calendar.MONTH, 1);// 加一个月,变为下月的1 号
lastDate.add(Calendar.DATE, -1);// 减去一天,变为当月最后一天
return lastDate.getTime();
}
}
posted on 2011-06-13 11:51
墙头草 阅读(264)
评论(0) 编辑 收藏