SimpleDateFormat sDateFormat ;

String date;

if(DateFormat.is24HourFormat(getActivity().getApplicationContext())){

  sDateFormat = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");

  date = sDateFormat.format(new java.util.Date());

}else{

  sDateFormat = new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss");

  date = sDateFormat.format(new java.util.Date()) + getPeroidText();

}

 

 

 

private CharSequence getPeroidText(){

   String am_pm =Calendar.getInstance().getTime().getHours() >= 12 ? "PM" : "AM";

  return am_pm;

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-05
  • 2022-02-21
  • 2022-12-23
  • 2021-06-29
  • 2021-09-14
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2022-12-23
相关资源
相似解决方案