Convert string to Date in java

前端 未结 6 1397
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 02:30

I\'m trying to parse a string to a date field in an android application but I can\'t seem to get it correct. Here is the string I\'m trying to convert to a date \"03/26/2012

6条回答
  •  無奈伤痛
    2020-11-30 02:44

    String str_date="13-09-2011";
    DateFormat formatter ; 
    Date date ; 
    formatter = new SimpleDateFormat("dd-MM-yyyy");
    date = (Date)formatter.parse(str_date); 
    System.out.println("Today is " +date.getTime());
    

    Try this

提交回复
热议问题