How can I change date from 24-hours format to 12-hours format (am/pm) in android

后端 未结 7 625
Happy的楠姐
Happy的楠姐 2021-01-14 16:56
Calendar ci = Calendar.getInstance();

CiDateTime = \"\" + (ci.get(Calendar.MONTH) + 1) +  
    \"/\" + ci.get(Calendar.DAY_OF_MONTH) + 
    \"/\" + ci.get(Calendar.         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-14 17:24

    public static final String TIME_FORMAT = "hh:mm aa";
    SimpleDateFormat TimeFormat = new SimpleDateFormat(TIME_FORMAT);
    
    Calendar ATime = Calendar.getInstance();
    String Timein12hourFormat = TimeFormat.format(ATime.getTime());
    

提交回复
热议问题