APISonar


com.baidu.hugegraph.testutil.Utils.date

> com > baidu > hugegraph > testutil > Utils > date
com APIs baidu APIs hugegraph APIs testutil APIs Utils APIs date APIs

Example 1
public void testTypeDate() throws ParseException {
        Date time = new Date();
        Assert.assertEquals(time, property("time", time));

        Date expected = Utils.date("2018-12-12 00:00:00.000");
        String date = "2018-12-12";
        Assert.assertEquals(expected, property("time", date));
        date = "2018-12-12 00:00:00";
        Assert.assertEquals(expected, property("time", date));
        date = "2018-12-12 00:00:00.000";
        Assert.assertEquals(expected, property("time", date));
    }
Example 2
public void testValueToDate() {
        Date date = Utils.date("2019-01-01 12:00:00");
        Assert.assertEquals(date, DataType.DATE.valueToDate(date));
        Assert.assertEquals(date,
                            DataType.DATE.valueToDate("2019-01-01 12:00:00"));
        Assert.assertEquals(date, DataType.DATE.valueToDate(date.getTime()));

        Assert.assertNull(DataType.TEXT.valueToDate("2019-01-01 12:00:00"));
        Assert.assertNull(DataType.DATE.valueToDate(true));
    }