converting date format

后端 未结 5 1429
我寻月下人不归
我寻月下人不归 2020-12-04 03:00

I got date as \'14-Dec-2010\' i want to get the month in number format for the given date. that is., i want to convert the date to \'14-12-2010\'.<

5条回答
  •  日久生厌
    2020-12-04 03:51

    DateFormat format = new SimpleDateFormat("dd-MMM-yyyy");
    Date date= format.parse("14-Dec-2010");
    

    This is how you will get Date Object now you can print it in any format.
    Note: month starts from 0 , so for Dec it would be 11

    • Here is working IDE One demo
    • Document

提交回复
热议问题