Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
satish4ru
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified
Accepted Solution

time in 24 hour format

 

Date date = new Date();
SimpleDateFormat sdFormat2 = new SimpleDateFormat("hh:mm");					DateField dateField2 = new DateField("TIME Mode", date						.getTime(), sdFormat2);

 

here i am getting time 12Hours Format but i want in 24 hours Format please help me how to get that

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: time in 24 hour format

From the Java doc -

 

SimpleDateFormat sdFormat2 = new SimpleDateFormat("HH:mm");

Developer
satish4ru
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified

Re: time in 24 hour format

no peter again it is taking same 12 hours Format ....

 

i watched in java doc also ther also mentioned same but i dont what happening i am getting again 12 hours format value...

Date date = new Date();
SimpleDateFormat sdFormat2 = new SimpleDateFormat("HH:mm");
DateField dateField2 = new DateField("TIME Mode", date				.getTime(), sdFormat2);

 

 

Developer
Eugen
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE

Re: time in 24 hour format

Looks like it uses system property in anycase. It just grab style (DATE, TIME or DATE_TIME) from formatter.

But I think it's correct. If user prefer to see 12h format why to force hime using the 24h format?

 

I'm also excited about current mess in DateField constructors from JavaDoc. They look pretty the same but some of them are depricated. Cool!

Developer
Eugen
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE

Re: time in 24 hour format

Choose in device options to use 24h format and you will se it in DateField.
Developer
satish4ru
Posts: 329
Registered: ‎12-17-2010
My Device: Not Specified

Re: time in 24 hour format

Sorry it is working fine due Debugger problem ....... 

 

Solution is 

 

Date date = new Date();
	SimpleDateFormat sdFormat2 = new SimpleDateFormat("HH:mm");
DateField dateField2 = new DateField("TIME Mode", date
							.getTime(), sdFormat2);

 

 

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: time in 24 hour format

And the difference between this and what I suggested is?

Developer
mtatro
Posts: 105
Registered: ‎06-23-2010
My Device: 9000

Re: time in 24 hour format

:-)

-matt

Press Kudos if this helped - ;-)