convert string to date type

后端 未结 2 1794
再見小時候
再見小時候 2021-01-26 05:24

I want to convert string to date format, but the following way didn\'t work.

It yields null for birth.

2条回答
  •  悲哀的现实
    2021-01-26 05:54

    Your code works fine. If you care to use Joda Time you can use this. You can go through the documentation to unleash the complete functionality in case you plan to use the time for DB testing and stuff.

    import org.joda.time.DateTime;
    DateTime dt = new DateTime("YYYY-MM-DD");//new DateTime("2012-03-30")
    System.out.println(dt);
    

提交回复
热议问题