Solved

saving 12:00:00 in db2

Posted on 2011-02-17
7
500 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 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