public class XMLUtils extends Object
Java class provides a collection Java methods for XML utilities.| Constructor and Description |
|---|
XMLUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeEntities(String s)
Escapes characters <, >, ', " and &,
replacing them by <, >, ', ",
and &.
|
static String |
formatDate(Date date)
Formats a date in ISO 8601 date format.
|
static String |
formatDateTime(Date date)
Formats a date and a time in ISO 8601 date time format.
|
static Date |
parseAndValidateDate(String date)
Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
|
static Date |
parseAndValidateDate(String date,
boolean onlyISO8601)
Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
|
static Date |
parseDate(String date)
Parses a date in ISO 8601 format (without date coherence verifications) or in milliseconds since January 1, 1970, 00:00:00 GMT.
|
static String |
toString(String tagName,
IXMLMarshallable model)
Returns the XML representation of the specified model as a string with the specified root element name.
|
static String |
toString(XMLMarshallable model)
Returns the XML representation of the specified model as a string.
|
static String |
toString(XMLMarshallable model,
int indentLevel)
Returns the XML representation of the specified model as a string with the specified indentation level.
|
public static String formatDate(Date date)
date - The date to formatpublic static String formatDateTime(Date date)
date - The date to formatpublic static String escapeEntities(String s)
s - The string to escapepublic static Date parseDate(String date)
date - The string to parsepublic static Date parseAndValidateDate(String date, boolean onlyISO8601) throws IllegalArgumentException, NullPointerException, RuntimeException
date - The string to parseonlyISO8601 - true if the parsing must accept only the ISO 8601 formatIllegalArgumentException - when the argument does not validate the ISO 8601NullPointerException - when the argument is nullRuntimeException - can be thrown by the Java APIpublic static Date parseAndValidateDate(String date) throws IllegalArgumentException, NullPointerException, RuntimeException
date - The string to parseIllegalArgumentException - when the argument does not validate the ISO 8601NullPointerException - when the argument is nullRuntimeException - can be thrown by the Java APIpublic static final String toString(String tagName, IXMLMarshallable model)
tagName - the name of the root elementmodel - the model to marshalpublic static final String toString(XMLMarshallable model)
model - the model to marshalpublic static final String toString(XMLMarshallable model, int indentLevel)
model - the model to marshalindentLevel - the indentation level