cancel
Showing results for 
Search instead for 
Did you mean: 

Problems while storing Timestamp into Max db

Former Member
0 Kudos

Hai All,

I am getting problem while inserting Timestamp into Maxdb

Here iam giving Timestamp as input to the entityBean , and in database also i was taken that field as timestamp.

the following is the code snippert,

Date dte=new Date();

Calendar c = Calendar.getInstance();

java.sql.Timestamp t=new Timestamp(c.getTimeInMillis());

try {

objTestingEntityLocalHome.create(strArg1,intarg2,dblDouble,t);

} catch (CreateException e) {

return "Ex" +e;

}catch (Exception e) {

return "Ex: "+e;

}

whenever I run this program it is insering date correctly, but time stamp is inserting incurrectly,it is not inserting current time stamp of the server

anybody please help me inthis regard

thanks

somu

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

try this:

GregorianCalendar c = new GregorianCalendar();
java.sql.Timestamp t=new Timestamp(c.getTimeInMillis());

Good luck,

Roelof

Former Member
0 Kudos

hai Knibbe

it is also getting same problem

are there is any otherway

Thanks & Regards

somu

Former Member
0 Kudos

Hi Somu,

use

java.sql.Timestamp t=new Timestamp(System.currentTimeMillis());

This will surely work

regards,

Sujesh