Calendar date to yyyy-MM-dd format in java

后端 未结 9 913
别跟我提以往
别跟我提以往 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:39

    In order to parse a java.util.Date object you have to convert it to String first using your own format.

    inActiveDate = format1.parse(  format1.format(date)  );
    

    But I believe you are being redundant here.

提交回复
热议问题