Example usage for org.json ISO8601 format

List of usage examples for org.json ISO8601 format

Introduction

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

Prototype

public static String format(Calendar cal) 

Source Link

Document

Formats a Calendar value into an ISO8601-compliant date/time string.

Usage

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

public String getJsonValue() {
    if (type == PropertyType.DATE) {
        return ISO8601.format(getDate());
    } else if (type == PropertyType.LONG) {
        return getLong().toString();
    }/*from  w  w w  .j  a v  a 2  s.  c o m*/
    if (type == PropertyType.DOUBLE) {
        return getDouble().toString().replace(",", ".");
    } else if (type == PropertyType.BOOLEAN) {
        return ((Boolean) convertedValue) == true ? "true" : "false";
    } else if (convertedValue != null) {
        return convertedValue.toString();
    }
    return null;
}

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

private ContentBody generateTextBody(String key, Object value) throws Exception {
    String mimeType = MimeTypeHelper.TEXT;
    String valStr = value.toString();
    if (value instanceof Date) {
        mimeType = "jcr-value/" + PropertyType.TYPENAME_DATE.toLowerCase();
        valStr = ISO8601.format((Date) value);
    }//from  w  ww.j  a va  2s  .  com
    if (value instanceof Long) {
        mimeType = "jcr-value/" + PropertyType.TYPENAME_LONG.toLowerCase();
        valStr = value.toString();
    }
    if (value instanceof Double) {
        mimeType = "jcr-value/" + PropertyType.TYPENAME_DOUBLE.toLowerCase();
        valStr = value.toString().replace(',', '.');
    }
    if (value instanceof Boolean) {
        mimeType = "jcr-value/" + PropertyType.TYPENAME_BOOLEAN.toLowerCase();
        valStr = value.toString().toLowerCase();
    }
    if (key.endsWith("jcr:data")) {
        mimeType = "jcr-value/binary";
    }
    StringBody res = new StringBody(valStr, mimeType, UTF_8);
    return res;
}