0

hi i want to display time in my application in the format of HH:mm AM/PM. Digital clock includes seconds also. That is HH:mm:ss am/pm. how to avoid showing seconds. Is there any possible way. Kindly help me out.

Ragunath Jawahar
  • 19,513
  • 22
  • 110
  • 155
user562237
  • 775
  • 5
  • 15
  • 24

2 Answers2

5

You have to make a clone of the file DigitalClock.java to use in your application, modify in the following manner:-

private final static String m12 = "h:mm aa";
private final static String m24 = "k:mm";

The path of DigitalClock.java : Here

Ram kiran Pachigolla
  • 20,897
  • 15
  • 57
  • 78
abhishek kumar gupta
  • 2,189
  • 6
  • 35
  • 56
0
import java.text.DateFormat;
import java.text.SimpleDateFormat;

// ... 
DateFormat format = new SimpleDateFormat("HH:mm a");
String formatted = format.format(myDate);
Jim Blackler
  • 22,946
  • 12
  • 85
  • 101