Reputation: 191
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:
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
Upvotes: 1
Views: 107
Reputation: 2632
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:
Hope it helps.
Regards
Upvotes: 0
Reputation: 3570
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);
Hope it helps.
Upvotes: 3