cancel
Showing results for 
Search instead for 
Did you mean: 

Error while saving date value in Java dictionary

Former Member
0 Kudos

Hello Everybody,

I got following error while saving date value in one of the fields of the Java table.

Internal error occured in submit request: Error in method updateRequestContact : The object of type java.sql.Date with the value '2005-12-04 08:00:00.0' assigned to host variable 9 is not normalized. It must not contain time components in the time zone running the virtual machine.

I can't find why it is taking time value in the date object.

This value is coming from the RFC as a date value, and I am saving this value in Java dictionary table.

Same code for this was working fine earlier. But, now suddenly it gives error like this.

Even if I provide date on the screen from webdynpro application, this date value can't save in the Java dictionary and gives same error.

What should be the problem behind this?

Regards,

Bhavik

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bhavik,

From the Javadocs,

"To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated."

Can you share the code where you are saving the date?

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

I am getting date value from the screen of the webdynpro application from date picker control and passing this value in Java dictionary.

More Information:

I have dat value in the Date object: <b>target_date</b>

But Now I have made new Date object as following:

Date target_Date1 = new Date(target_date.getYear(),target_date.getMonth(),target_date.getDate());

Then I am passing this object to Java dictionary. Still it gives same error.

Then I have changed code as following:

int l_year;

int l_month;

int l_days;

l_year = target_Date.getYear();

l_month = target_Date.getMonth();

l_days = target_Date.getDate();

Date target_Date1 = new Date(l_year,l_month,l_days);

Now it works for me.

But I guess this is not the perment solution. It looks very strange. I have used so many date objects at various palces. So, this solution is not the final for me.

I want to findout the main cause of it.

One more thing: This code was working for a mornth or two. But, now suddenly it is giving this error.

Please help me if anybody knows.

Regards,

Bhavik

Former Member
0 Kudos

Hi Bhavik,

Here are a few informations that might help you understand the problem:

java.sql.Date is a wrapper extending java.util.Date, which has both Date and Time components.

java.sql.Date should carry only date information and a normalized instance has the time information set to zero.

From your original mail, the value that you were getting was not normalized, since it had a non-zero time value.

So all you have to do is, create a normalized instance of the Date object and save this instance.

You can create normalized java.sql.Date objects by using the

java.sql.Date.valueOf(String)

method.

So you can try converting your

target_date

to String and then call the above mentioned method.

You might want to check the "Checklist for Java Persistence" available <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/43/373ea0fe30321ae10000000a422035/content.htm">here.</a>

Regards,

Satyajit.