APISonar


com.orientechnologies.orient.core.metadata.schema.OType.DATE

> com > orientechnologies > orient > core > metadata > schema > OType > DATE
com APIs orientechnologies APIs orient APIs core APIs metadata APIs schema APIs OType APIs DATE APIs

Example 1
public void testDateTypes() throws ParseException {
		ODocument doc = new ODocument();
		doc.field("context", "test");
		doc.field("date", System.currentTimeMillis(), OType.DATE);

		Assert.assertTrue(doc.field("date") instanceof Date);

	}
Example 2
private void initSchema() {
    OClass testClass = db.getMetadata().getSchema().createClass("Test");
    testClass.createProperty("date", OType.DATE);
    ODocument document = new ODocument(testClass.getName());

    try {
      document.field("date", new SimpleDateFormat(dateFormat).parse(dateValue));
      document.save();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    db.commit();
  }
Example 3
public void testDefaultValueMandatoryReadonlyFromJson() {
    OSchema schema = database.getMetadata().getSchema();
    OClass classA = schema.createClass("ClassA");

    OProperty prop = classA.createProperty("date", OType.DATE);
    prop.setMandatory(true);
    prop.setReadonly(true);
    prop.setDefaultValue(ODateHelper.getDateTimeFormatInstance().format(new Date()));

    ODocument doc = new ODocument().fromJSON("{'@class':'ClassA','other':'other'}");
    ODocument saved = database.save(doc);
    assertNotNull(saved.field("date"));
    assertTrue(saved.field("date") instanceof Date);
    assertNotNull(saved.field("other"));
  }