Solved

saving 12:00:00 in db2

Posted on 2011-02-17
7
522 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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:Kent Olsen
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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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