How to convert string to date object?

前端 未结 5 2164
不知归路
不知归路 2020-12-22 03:47
String date=\"2006-06-21T15:57:24.000Z\";

How do I convert this String to a Date object without changing this format in Android?

5条回答
  •  长情又很酷
    2020-12-22 04:30

    I came here because this was supposedly an answered question of Covert RFC3339 DateTime to Date in java. However, Time is a deprecated class in Android since API level 22.

    A simple answer is based on this one:

    import com.google.api.client.util.DateTime;
    
    Date date = new Date(new DateTime("2006-06-21T15:57:24.000Z").getValue());
    

提交回复
热议问题