Solved

Time format JAVA

Posted on 2006-10-26
3
206 Views
Last Modified: 2012-05-05
Hi,
i have a question ...

String DATE_FORMAT = "yyyy-MM-dd hh:mm:ss";

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
Calendar c1 = Calendar.getInstance();

c1.set(Integer.parseInt(cYear), Integer.parseInt(cMonth)-1, Integer.parseInt(cDate), Integer.parseInt(cHour), Integer.parseInt(cMinute), Integer.parseInt(cSecond));
System.out.println(sdf.format(c1.getTime())));

the line with system out gives: 2006-10-05 08:00:11
but in reality it should be :  2006-10-05 20:00:11
How can i tell it to use military time?
Please help,
Thank you
0
Comment
Question by:Squadless
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
hoomanv earned 500 total points
ID: 17814869
use HH instead of hh
0
 
LVL 1

Author Comment

by:Squadless
ID: 17814896
LIFE SAVER MAN, thanks a lot...u seem to be answering lot of my questions...keep it up and when i get a raise ill buy you a house :)
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17814921
:)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now