How to receive input as yyyyMMddHHmm format in java?

后端 未结 3 897
天命终不由人
天命终不由人 2021-01-21 07:33
SimpleDateFormat sdf = new SimpleDateFormat(\"yyyyMMddHHmm\");
java.util.Date parsedDate = sdf.parse(\"201212130900\");
java.sql.Timestamp timestamp = new java.sql.Times         


        
3条回答
  •  太阳男子
    2021-01-21 08:13

    In java, to get a formated date, you would do the following:

    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmm");
    String sdf.format(myDate);
    

    There are loads of options in SimpleDateFormat. I have attached the JavaDoc for you.

提交回复
热议问题