JodaFormatter

public class JodaFormatter

Class responsible for parsing and formatting several classes from org.joda.time package.

Constructors

JodaFormatter

public JodaFormatter()

Default constructor.

Methods

formatDateTime

public String formatDateTime(DateTime dateTime)

Formats DateTime as text.

Parameters:
  • dateTime – the DateTime to be formatted.
Returns:

the text representing the DateTime

formatPeriod

public String formatPeriod(Period period)

Formats Joda period as text, eg: “1 year”

Parameters:
  • period – time interval
Returns:

the text representing the period

parse

public Period parse(String intervalString, Locale locale)

Parses time interval in different units, eg: “1 year”

Parameters:
  • intervalString – time interval format number: integer unit : year, month, week, day, hour, minute, second (can use plural forms also) currently compound units like 1 year and 2 months are not supported
  • locale – the locale to be used when parsing given String
Returns:

the given String parsed to import org.joda.time.Period

parseDateTime

public DateTime parseDateTime(String isoDateTime)

Parses given String to DateTime.

Parameters:
  • isoDateTime – the string to be parsed, must be using ISO-8601 standard
Returns:

the DateTime parsed from String

parsePeriod

public Period parsePeriod(String intervalString)

Parses time interval in different units, eg: “1 year”

Parameters:
  • intervalString – time interval format number: integer unit : year, month, week, day, hour, minute, second (can use plural forms also) currently compound units like 1 year and 2 months are not supported
Returns:

the given String parsed to import org.joda.time.Period