本文整理汇总了Java中org.apache.olingo.commons.core.edm.primitivetype.EdmDate类的典型用法代码示例。如果您正苦于以下问题:Java EdmDate类的具体用法?Java EdmDate怎么用?Java EdmDate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdmDate类属于org.apache.olingo.commons.core.edm.primitivetype包,在下文中一共展示了EdmDate类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDate
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; //导入依赖的package包/类
private static Date toDate(String sourceValue) {
try {
return EdmDateTimeOffset.getInstance().valueOfString(
sourceValue,
true,
null,
null,
null,
null,
Date.class);
} catch (EdmPrimitiveTypeException dateTimeOffsetException) {
try {
return EdmDate.getInstance().valueOfString(
sourceValue,
true,
null,
null,
null,
null,
Date.class);
} catch (EdmPrimitiveTypeException e) {
throw new IllegalStateException("Cannot convert to EdmDate: " + sourceValue, e);
}
}
}
示例2: createProperty_DateFieldsAndNullValue_PropertyWithNullValueCreated
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; //导入依赖的package包/类
@Test
public void createProperty_DateFieldsAndNullValue_PropertyWithNullValueCreated() {
doReturn(getTypedProperty(EdmDateTimeOffset.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, null, entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
assertNull(property.getValue());
doReturn(getTypedProperty(EdmDate.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, null, entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
assertNull(property.getValue());
}
示例3: createProperty_DateFieldAndDateAsString_PropertyWithCalendarCreated
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; //导入依赖的package包/类
@Test
public void createProperty_DateFieldAndDateAsString_PropertyWithCalendarCreated() {
doReturn(getTypedProperty(EdmDate.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY,
"1992-06-24T00:00:00.000Z", entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
Object calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1992, 5, 24, 0, 0, 0, 0, (GregorianCalendar) calendar);
// Case where date less than 1582 year
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, "1256-05-01T00:00:00.000Z",
entityType);
calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1256, 4, 1, 0, 0, 0, 0, (GregorianCalendar) calendar);
}
示例4: createProperty
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; //导入依赖的package包/类
/**
* Creates property using name, value and entity type.
*
* @param name
* property name
* @param value
* property value
* @param entityType
* entity type
* @return property instance
*/
@SuppressWarnings("unchecked")
public Property createProperty(String name, Object value, ElasticEdmEntityType entityType) {
EdmElement property = entityType.getProperty(name);
if (value instanceof List) {
return createPropertyList(name, (List<Object>) value, entityType);
} else if (value instanceof Map) {
return createComplexProperty(name, (Map<String, Object>) value,
entityType.getProperty(name));
} else if (property != null) {
Object modifiedValue = value;
if (property.getType() instanceof EdmDate
|| property.getType() instanceof EdmDateTimeOffset) {
modifiedValue = value != null ? convertDateValue(value) : null;
} else if (property.getType() instanceof EdmBoolean && value instanceof Long) {
// When Elasticsearch aggregates data it return's boolean as
// number value (1,0), but when it searches then normal boolean
// value will be retrieved
modifiedValue = (Long) value != 0;
} else if (property.getType() instanceof EdmSingle && value instanceof Double) {
// Because Elasticsearch returns 'float' values as 'double'
// Link: https://github.com/elastic/elasticsearch/issues/25792
modifiedValue = new Float((Double) value);
}
return createPrimitiveProperty(name, modifiedValue);
} else {
return createPrimitiveProperty(name, value);
}
}
示例5: teiidType
import org.apache.olingo.commons.core.edm.primitivetype.EdmDate; //导入依赖的package包/类
public static String teiidType(SingletonPrimitiveType type) {
if (type instanceof EdmBinary) {
return odatakeyed.get(EdmPrimitiveTypeKind.Binary);
} else if (type instanceof EdmBoolean) {
return odatakeyed.get(EdmPrimitiveTypeKind.Boolean);
} else if (type instanceof EdmByte) {
return odatakeyed.get(EdmPrimitiveTypeKind.Byte);
} else if (type instanceof EdmDate) {
return odatakeyed.get(EdmPrimitiveTypeKind.Date);
} else if (type instanceof EdmDateTime) {
return odatakeyed.get(EdmPrimitiveTypeKind.DateTime);
} else if (type instanceof EdmDateTimeOffset) {
return odatakeyed.get(EdmPrimitiveTypeKind.DateTime);
} else if (type instanceof EdmDecimal) {
return odatakeyed.get(EdmPrimitiveTypeKind.Decimal);
} else if (type instanceof EdmDouble) {
return odatakeyed.get(EdmPrimitiveTypeKind.Double);
} else if (type instanceof EdmDuration) {
return odatakeyed.get(EdmPrimitiveTypeKind.Int32);
} else if (type instanceof EdmGuid) {
return odatakeyed.get(EdmPrimitiveTypeKind.String);
} else if (type instanceof EdmInt16) {
return odatakeyed.get(EdmPrimitiveTypeKind.Int16);
} else if (type instanceof EdmInt32) {
return odatakeyed.get(EdmPrimitiveTypeKind.Int32);
} else if (type instanceof EdmInt64) {
return odatakeyed.get(EdmPrimitiveTypeKind.Int64);
} else if (type instanceof EdmSByte) {
return odatakeyed.get(EdmPrimitiveTypeKind.SByte);
} else if (type instanceof EdmSingle) {
return odatakeyed.get(EdmPrimitiveTypeKind.Single);
} else if (type instanceof EdmStream) {
return odatakeyed.get(EdmPrimitiveTypeKind.Stream);
} else if (type instanceof EdmString) {
return odatakeyed.get(EdmPrimitiveTypeKind.String);
} else if (type instanceof EdmTimeOfDay) {
return odatakeyed.get(EdmPrimitiveTypeKind.Time);
}
return null;
}