java常用小技巧汇总

1.java实现日期加上天数:

public static void main(String[] args) {
   String createDate = "2008-12-01";
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
   try {
    Date date = sdf.parse(createDate);
    Calendar cl = Calendar.getInstance();
    cl.setTime(date);
    cl.add(Calendar.DATE,1);
    String temp = "";
    temp = sdf.format(cl.getTime());
    System.out.println(temp);
   } catch (ParseException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
}

你可能感兴趣的:(j2se)