Calendar months wrong

前端 未结 3 1625
栀梦
栀梦 2021-01-23 03:16

I try to set a simple date certain years after with calendar:

String date is a parameter of this metod.

     SimpleDateFormat format = new SimpleDateForm         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-23 03:37

    You are using lowercase "m" for month, when you should be using uppercase "M", i.e

    SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
    

    lowercase "m" is used to format minutes - see the java API for SimpleDateFormat for more details.

提交回复
热议问题