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.
Asked
Active
Viewed 8,591 times
0
-
i am using digital clock to display my time – user562237 Apr 07 '11 at 10:31
-
Try this : http://bakhtiyor.com/page/6/ – Kartik Domadiya Apr 07 '11 at 10:41
2 Answers
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
-
1As all the properties of the DigitalClock are private, you'll have to copy and paste the source as described. – David Snabel-Caunt Nov 22 '11 at 10:57
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