1
votes

I have experimenting error storing date in the database v.2.2.5. Here is the code:

OrientVertex ov = sm.getGraphdb().getVertex("12:1177");
Date d = new Date(2016, 7, 29);
Date dt =new Date(2016, 7, 29, 12, 0);

ov.setProperty("date", d);
ov.setProperty("datetime", dt);
...

when I check in the DB I see:

enter image description here

but if I store date inside the DB with this:

update #12:1177 set fromODBDate = '2016-08-29'

I see it in the correct way. Somebody know what is wrong?

Thanks Marcelo

2

2 Answers

3
votes

You could use

Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 2000);
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DAY_OF_MONTH, 1);

Date d=new Date(cal.getTimeInMillis());

ov.setProperty("date", d);

enter image description here

Hope it helps.

0
votes

Try this:

OrientVertex ov = g.getVertex("#12:1177");
ov.setProperty("date", "2016-7-29", OType.DATE);
ov.setProperty("datetime","2016-7-29 12:00:00", OType.DATETIME);

This is the output:

enter image description here

Hope it helps.

Regards