public class

DateConverter

extends AbstractSingleValueConverter
java.lang.Object
   ↳ com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter
     ↳ com.thoughtworks.xstream.converters.basic.DateConverter

Class Overview

Converts a java.util.Date to a String as a date format, retaining precision down to milliseconds.

Summary

Public Constructors
DateConverter()
Construct a DateConverter with standard formats and lenient set off.
DateConverter(boolean lenient)
Construct a DateConverter with standard formats.
DateConverter(String defaultFormat, String[] acceptableFormats)
Construct a DateConverter with lenient set off.
DateConverter(String defaultFormat, String[] acceptableFormats, boolean lenient)
Construct a DateConverter.
Public Methods
boolean canConvert(Class type)
Determines whether the converter can marshall a particular type.
Object fromString(String str)
Unmarshals an Object from its single value representation.
String toString(Object obj)
Marshals an Object into a single value representation.
[Expand]
Inherited Methods
From class com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter
From class java.lang.Object
From interface com.thoughtworks.xstream.converters.ConverterMatcher
From interface com.thoughtworks.xstream.converters.SingleValueConverter

Public Constructors

public DateConverter ()

Construct a DateConverter with standard formats and lenient set off.

public DateConverter (boolean lenient)

Construct a DateConverter with standard formats.

Parameters
lenient the lenient setting of setLenient(boolean)

public DateConverter (String defaultFormat, String[] acceptableFormats)

Construct a DateConverter with lenient set off.

Parameters
defaultFormat the default format
acceptableFormats fallback formats

public DateConverter (String defaultFormat, String[] acceptableFormats, boolean lenient)

Construct a DateConverter.

Parameters
defaultFormat the default format
acceptableFormats fallback formats
lenient the lenient setting of setLenient(boolean)

Public Methods

public boolean canConvert (Class type)

Determines whether the converter can marshall a particular type.

Parameters
type the Class representing the object type to be converted

public Object fromString (String str)

Unmarshals an Object from its single value representation.

Parameters
str the String with the single value of the Object
Returns
  • the Object

public String toString (Object obj)

Marshals an Object into a single value representation.

Parameters
obj the Object to be converted
Returns
  • a String with the single value of the Object or null