I think you want to use the HH format, rather than 'hh' so that you are using hours between 00-23. 'hh' takes the format in 12 hour increments, and so it assumes it is in the AM.
I think you want to use the HH format, rather than 'hh' so that you are using hours between 00-23. 'hh' takes the format in 12 hour increments, and so it assumes it is in the AM. So this SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf.
Parse("2009-08-19 12:00:00"); System.out. Print(date.toString()); Should print out Wed Aug 19 12:00:00 EDT 2009.
The hour should be specified as HH instead of hh. Check out the section on Date and Time patterns in java.sun.com/javase/6/docs/api/java/text....
You're printing out the toString() representation of the date, rather than the format's representation. You may also want to check the hour representation. H and h mean something different.
H is for the 24 hour clock (0-23), h is for the 12 hour clock (1-12), (there is also k and K for 1-24 and 0-11 based times respectively) You need to do something like: //in reality obtain the date from elsewhere, e.g. New Date() Date date = sdf. Parse("2009-08-19 12:00:00"); //this format uses 12 hours for time SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //this format uses 24 hours for time SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out. Print(sdf.
Format(date)); System.out. Print(sdf2. Format(date)).
I'll try that, but I don't think it's going to solve the problem. In my application, I'm not actually converting back to a string. I'm saving the Date to a database, and it's wrong there, too.
– MДΓΓ БДLL Aug 21 '09 at 17:44 Are your format strings consistent? Some DBMSs will automatically convert values if they can figure things out, some won't. Are the problematic values in a column(s) with different formatting applied at the db level?
Or coming from a connection that's got different parameters set? – DaveE Aug 21 '09 at 18:03.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.