Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
JDBC Date Format Error with DB2

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
RadhikaMurthy

New User


Joined: 28 Jun 2007
Posts: 1
Location: Hyderabad,India

PostPosted: Fri Jun 29, 2007 5:08 pm    Post subject: JDBC Date Format Error with DB2
Reply with quote

When working with dates in DB2, I got the following error.

java.lang.IllegalArgumentException: Date/Time must be JDBC format

I have no access to the java application that is used with database. We need to post everything in the form of XML data

Any solution for sorting out the abive problem?
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Jun 29, 2007 7:32 pm    Post subject:
Reply with quote

Hello,

Talk with whoever is responsible for the java application and have them describe how the date must be formatted for their use.

From your post it is not clear just where the problem is occurring - it mainframe code having a problem or is the problem elsewhere?

A bit of web search did find this and maybe it will help. . .
Quote:
Re: jdbc date format error
--------------------------------------------------------------------------------

The error message indicates that date1 must be a java.sql Date variable.
If you want to avoid using depreciated functions, you should instantiate
a java.util.Calendar object, set the date (and time) you want, then use
its getTimeInMillis() method to get the value needed to create the
java.sql.Date object. Java dates are based on milliseconds since the
start of the current epoch - Jan 1, 1970 - 00:00:00. Since this is your
default date, you should be able to use:
import java.sql.*;
Date date1 = new Date(0);

Check that this works before using it. On my system, Date(0) gives:
12/31/1969 - 19:00:00
This is probably caused by the offset between GMT and EST.

Calendar c1 - Calendar.getInstance();
c1.set(1970,c1.JANUARY,01,00,00,00);
Date date2 = new Date(c1.getTimeInMillis());

Using the Calendar object creates the 1/1/1970 date you want.

If you also have an import for java.util.*; you will need to use:
java.sql.Date date1 = new java.sql.Date(c1.getTimeInMillis());

Phil Sherman
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Format issues using XMITIP MSGDD ssdjp1 CLIST & REXX 3 Mon Oct 23, 2017 8:47 pm
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 11 Fri Sep 22, 2017 11:35 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us