Solved

saving 12:00:00 in db2

Posted on 2011-02-17
7
510 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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