Example usage for org.json ISO8601 parseToDate

List of usage examples for org.json ISO8601 parseToDate

Introduction

In this page you can find the example usage for org.json ISO8601 parseToDate.

Prototype

public static Date parseToDate(String text) 

Source Link

Usage

From source file:org.jkan997.slingbeans.slingfs.FileObjectAttribute.java

public void setJsonValue(JSONObject jsonObj, String propName) {
    propertyName = propName;// www  .  j a  v  a2s .  co  m
    Object value = jsonObj.get(propName);
    String name = jsonObj.getString(":" + propName);
    type = JcrTypeHelper.getType(name, value);
    this.readOnly = readOnlyProps.contains(propertyName);
    hidden = (propName.startsWith(":"));
    if (type == PropertyType.DATE) {
        convertedValue = ISO8601.parseToDate(value.toString());
        this.readOnly = true;
    } else if (type == PropertyType.LONG) {
        convertedValue = ((Number) value).longValue();
    } else if (type == PropertyType.DOUBLE) {
        convertedValue = (Double) value;
    } else if (type == PropertyType.BOOLEAN) {
        convertedValue = (Boolean) value;
    } else if (type == PropertyType.STRING) {
        convertedValue = (String) value;
    } else if (value != null) {
        convertedValue = value.toString();
        readOnly = true;
    } else {
        convertedValue = "null";
        readOnly = true;
    }
}

From source file:org.jkan997.slingbeans.slingfs.FileObjectAttribute.java

public void setXmlValue(String value, String propName) {
    if (readOnlyProps.contains(propName)) {
        this.readOnly = true;
    }/*www . ja v a2  s . c  o  m*/
    propertyName = propName;
    int type = PropertyType.STRING;
    if (value.startsWith("{")) {
        int ind = value.indexOf("}");
        if (ind > 0) {
            String typeStr = value.substring(1, ind);
            value = value.substring(ind + 1);
            type = PropertyType.valueFromName(typeStr);
        }
    }
    if (type == PropertyType.DATE) {
        convertedValue = ISO8601.parseToDate(value.toString());
        readOnly = true;
    } else if (type == PropertyType.LONG) {
        convertedValue = Long.parseLong(value);
    } else if (type == PropertyType.DOUBLE) {
        convertedValue = Double.parseDouble(value);
    } else if (type == PropertyType.BOOLEAN) {
        convertedValue = "true".equalsIgnoreCase(value);
    } else if (type == PropertyType.STRING) {
        convertedValue = value;
    } else if (value != null) {
        convertedValue = value;
        readOnly = true;
    } else {
        convertedValue = "null";
        readOnly = true;
    }
}