How to convert date from MM/YYYY to MM/DD/YYYY in Java

后端 未结 4 1204
名媛妹妹
名媛妹妹 2021-01-25 03:55

I want to convert date from MM/YYYY to MM/DD/YYYY, how i can do this using SimpleDateFormat in Java? (Note: DD can be start date of that month)

4条回答
  •  清酒与你
    2021-01-25 04:30

    please go through the http://download.oracle.com/javase/1.5.0/docs/api/java/text/DateFormat.html following link for more clarity.

    One way of implementation i have in my mind is :

    String yourDate = 
    DateFormat dateFormat= new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
    Date date= new Date();
    date = (Date)dateFormat.parse(yourDate);
    //String dateString= dateFormat.format(date);
    /*Print your date*/
    

    Please go through this link SimpleDateFormat

提交回复
热议问题