How to format date and time in Android?

前端 未结 24 1296
面向向阳花
面向向阳花 2020-11-22 00:51

How to format correctly according to the device configuration date and time when having a year, month, day, hour and minute?

24条回答
  •  不知归路
    2020-11-22 01:15

    Try:

    event.putExtra("startTime", "10/05/2012");
    

    And when you are accessing passed variables:

    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
    Date date = formatter.parse(bundle.getString("startTime"));
    

提交回复
热议问题