unable to convert string date in Format yyyyMMddHHmmss to DateTime dart

后端 未结 6 817
不知归路
不知归路 2021-02-07 01:49

i have a string containing date in format yyyyMMddHHmmss (e.g.) (20180626170555) and i am using following code to convert it into date time

dateTimeFromString(         


        
6条回答
  •  孤独总比滥情好
    2021-02-07 02:02

    You can use DateFormat to parse a DateTime from string to an object

    // With en_US locale by default
    var newDateTimeObj = new DateFormat().add_yMd().add_Hms().parse("7/10/1996 10:07:23")
    // with a defined format
    var newDateTimeObj2 = new DateFormat("dd/MM/yyyy HH:mm:ss").parse("10/02/2000 15:13:09")
    

    Check the doc here.

提交回复
热议问题