?
Solved

saving 12:00:00 in db2

Posted on 2011-02-17
7
Medium Priority
?
526 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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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 46

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 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