Convert a {@link JsonNode} to {@link Date}. If the target node is a string, parse it as a
{@link Date} using the specified date-time format.

@param node
@return
@since 0.6.3.1
762366
public static Date convertDate(JsonNode node, String dateTimeFormat) {
        if (node instanceof POJONode) {
            return convertDate(DPathUtils.extractValue((POJONode) node), dateTimeFormat);
        }
        return node.isNumber() ? new Date(node.asLong())
                : node.isTextual() ? DateFormatUtils.fromString(node.asText(), dateTimeFormat)
                        : null;
    }
42323
public String serialize(Node node, boolean format) {
        Result result;
        StringWriter dest;

        if (node == null) {
            throw new IllegalArgumentException();
        }
        dest = new StringWriter();
        result = new StreamResult(dest);
        try {
            serialize(node, result, format);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        return dest.getBuffer().toString();
    }
456150
public JsonNode toJson() {
		ObjectNode node = new ObjectMapper().createObjectNode();
		node.put("code", code);
		if (format != null) {
			node.put("format", format);
		}
		return node;
	}
150421
public static String nodeToString(Node node)
    {
        StringWriter sw = new StringWriter();
        if (node instanceof Attr)
        {
            Attr attr = (Attr) node;
            return attr.getValue();
        }
        try
        {
            Transformer t = TransformerFactory.newInstance().newTransformer();
            t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            t.setOutputProperty(OutputKeys.INDENT, "no");
            t.transform(new DOMSource(node), new StreamResult(sw));
        }
        catch (TransformerException te)
        {
            LOG.warning("Transformer Exception: " + te.getMessage());
        }
        return sw.toString();
    }
358378
public static XMLGregorianCalendar convertDate(Date date) {
        if (date == null) {
            return null;
        }

        GregorianCalendar gc = new GregorianCalendar();
        gc.setTimeInMillis(date.getTime());

        try {
            return getDatatypeFactory().newXMLGregorianCalendar(gc);
        } catch (DatatypeConfigurationException ex) {
            return null;
        }
    }
826371
public static JsonNode parse(final String jsonString) {
        if (Strings.isEmpty(jsonString)) {
            return newObject();
        }

        try {
            return createObjectMapper().readValue(jsonString, JsonNode.class);
        } catch (Throwable e) {
            throw new ParseException(String.format("can't parse string [%s]", jsonString), e);
        }
    }
345343
@Override
    public Calendar convertDateToCalendar(java.util.Date date) {
        Calendar calendar = null;
        if (date != null) {
            calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.clear(Calendar.ZONE_OFFSET);
            calendar.clear(Calendar.DST_OFFSET);
        }
        return calendar;
    }
1277444
public static Boolean convertBoolean(JsonNode node) {
        if (node instanceof POJONode) {
            return convertBoolean(DPathUtils.extractValue((POJONode) node));
        }
        boolean value = node.isBoolean() ? node.asBoolean()
                : node.isTextual() ? Boolean.parseBoolean(node.asText()) : false;
        return Boolean.valueOf(value);
    }
474694
public static Date dateStringToDate(String dateString){
		SimpleDateFormat sdf=new SimpleDateFormat(DateTimeKit.FULL_DATE_24HR_STYLE);
		Date date = null;
		try {
			date = sdf.parse(dateString);
		} catch (ParseException e) {}  
		return date;
	}
680794
private Map<String, List<NumberPattern>> getPluralNumberPattern(JsonObject node) {
    Map<String, List<NumberPattern>> result = new LinkedHashMap<>();
    for (Map.Entry<String, JsonElement> entry : node.entrySet()) {
      String key = entry.getKey();
      String value = entry.getValue().getAsString();
      List<NumberPattern> formats = getNumberPattern(value);
      result.put(key, formats);
    }
    return result;
  }
166910
public JsonNode apply(final JsonNode node) {
        requireNonNull(node, "node");
        JsonNode ret = node.deepCopy();
        for (final JsonPatchOperation operation : operations) {
            ret = operation.apply(ret);
        }

        return ret;
    }
896395
private static final String getKey(ObjectNode node) {
        JsonNode apiVersion = node.get(API_VERSION);
        JsonNode kind = node.get(KIND);

        return getKey(apiVersion != null ? apiVersion.textValue() : null,
                      kind != null ? kind.textValue() : null);
    }
353178
public static Date parseDate(String date) throws JournalException {
        try {
            SimpleDateFormat parser = new SimpleDateFormat(TIMESTAMP_FORMAT);
            return parser.parse(date);
        } catch (ParseException e) {
            throw new JournalException(e);
        }
    }
451708
public static XMLGregorianCalendar convertDateToXMLGregorianCalendar(final Date date) {
        try {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTime(date);
            XMLGregorianCalendar calXml = DatatypeFactory.newInstance().newXMLGregorianCalendar(
                    cal.get(Calendar.YEAR),
                    cal.get(Calendar.MONTH) + 1,
                    cal.get(Calendar.DAY_OF_MONTH),
                    cal.get(Calendar.HOUR_OF_DAY),
                    cal.get(Calendar.MINUTE),
                    cal.get(Calendar.SECOND),
                    cal.get(Calendar.MILLISECOND),
                    0);
            return calXml;
        } catch (DatatypeConfigurationException e) {
            throw new SwidException("Cannot convert date", e);
        }
    }
614956
public static String node2String(final Node node) throws UnsupportedEncodingException
   {
      return node2String(node, true, Constants.DEFAULT_XML_CHARSET);
   }
51230
public static JsonNode toJson(final Object data) {
        if (data == null) {
            return newObject();
        }

        try {
            return createObjectMapper().valueToTree(data);
        } catch (Exception e) {
            throw new ParseException(e);
        }
    }
1344431
public static Date asDate(String expression, Node node, XPath xpath)
            throws XPathExpressionException {
        String dateString = evaluateAsString(expression, node, xpath);
        if (isEmptyString(dateString)) return null;

        try {
            return DateUtils.parseISO8601Date(dateString);
        } catch (Exception e) {
            log.warn("Unable to parse date '" + dateString + "':  " + e.getMessage(), e);
            return null;
        }
    }