Search code examples
javaorientdb

OrientDB: error storing Date


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


Solution

  • 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