Time mTime = new Time(); 

 

   mTime.setToNow(); 

 
CharSequence mCharSequence;          
  String style = "";
 

              if (hour >= 0 && hour < 12) { 

 

                  style = "AM"; 

 

              } else if (hour >= 12) { 

 

                  style = "PM"; 

 

              } 

 
 
 
 
 
 
 

              if (android.text.format.DateFormat.is24HourFormat(mContext)) { 

 

                  mCharSequence = DateFormat.format("kk:mm", mTime.toMillis(false)); 

 

              } else { 

 

                  mCharSequence = DateFormat.format("hh:mm", mTime.toMillis(false)) + " " + style; 

 

              }