Solved

saving 12:00:00 in db2

Posted on 2011-02-17
7
487 Views
Last Modified: 2012-08-14
Hello I,m trying to save a 12:00:00 PM value in a time column in db2, but for some reason it always get save as AM not PM

I'm using java


SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:");
	try {
			ps.setTime(19,new java.sql.Time((dateFormat.parse("12:00:00 PM")).getTime()));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			ps.setNull(19,java.sql.Types.TIME);
		}

Open in new window

0
Comment
Question by:cano63
  • 4
  • 2
7 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 34922583
how about using a 24 hours format and just specify 0 for the hours part?
0
 
LVL 1

Author Comment

by:cano63
ID: 34922618
I also try "12:00:00 but it keep saving it as 12:00:00 AM
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 34922626
did you try "00:00:00" ?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Author Comment

by:cano63
ID: 34922692
I ALSO TRY "00:00:00" BUT IT KEEP SAVING THE TIME IN am FORMART

IF I use 13:00:00 it save it as 1:00 PM without problem
0
 
LVL 45

Expert Comment

by:Kdo
ID: 34922758
Hi cano,

DB2 only has 1 storage format for a time.  There are numerous display formats, but only 1 internal time format.

Using a 24 hour display format, times can be from 00:00:00 to 23:59:59.  At 24:00:00 the time rolls to 00:00:00 and the date (if it's a datetime object) advances 1 day.

If you're not seeing the time in the format that you expect, the issue is in the function call, or possibly the ODBC/JDBC driver.  It is not a database issue.  


Ketn
0
 
LVL 1

Accepted Solution

by:
cano63 earned 0 total points
ID: 34922767
Found it

this was the problem
SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:");

it should be
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:");
0
 
LVL 1

Author Closing Comment

by:cano63
ID: 34986549
I found the problem
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

706 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

20 Experts available now in Live!

Get 1:1 Help Now