Calendar date to yyyy-MM-dd format in java

后端 未结 9 1062
别跟我提以往
别跟我提以往 2020-11-22 06:16

How to convert calendar date to yyyy-MM-dd format.

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1);
Date date = cal.getTime();          


        
9条回答
  •  爱一瞬间的悲伤
    2020-11-22 06:48

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, 7);
    Date date = c.getTime();
    SimpleDateFormat ft = new SimpleDateFormat("MM-dd-YYYY");
    JOptionPane.showMessageDialog(null, ft.format(date));
    

    This will display your date + 7 days in month, day and year format in a JOption window pane.

提交回复
热议问题