Class DateFormatting

  • All Implemented Interfaces:
    Formatting, I18n

    public class DateFormatting
    extends Object
    implements Formatting
    Provide some functions to get formatted date/time string.
    • Constructor Detail

      • DateFormatting

        public DateFormatting()
    • Method Detail

      • formatDate

        public String formatDate​(Object obj,
                                 String pattern,
                                 Locale locale)
        Get the formatted string of default time zone in specified pattern and specified Locale.
        Parameters:
        obj - The object which represents date, it can be Date, Calendar, timestamp in long, or ISO string. For ISO string, please refer to https://www.w3.org/TR/NOTE-datetime.
        pattern - The format you want the date string show in. Currently VIP supports 12 formats, they are full, long, medium, short, fullDate, longDate, mediumDate, shortDate, fullTime, longTime, mediumTime, shortTime. The first four formats combine date and time together. For the real pattern each format represents
        locale - The locale for which the date format is desired.
        Returns:
        The formatted date/time string.
      • formatDate

        public String formatDate​(Object obj,
                                 String pattern,
                                 String timeZone,
                                 Locale locale)
        Get the formatted string of specified time zone in specified pattern and specified Locale.
        Parameters:
        obj - The object which represents date, it can be Date, Calendar, timestamp in long, or ISO string. For ISO string, please refer to https://www.w3.org/TR/NOTE-datetime.
        pattern - The format you want the date string show in. Currently VIP supports 12 formats, they are full, long, medium, short, fullDate, longDate, mediumDate, shortDate, fullTime, longTime, mediumTime, shortTime. The first four formats combine date and time together. For the real pattern each format represents
        timeZone - The ID for a TimeZone, such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".
        locale - The locale for which the date format is desired.
        Returns:
        The formatted date/time string.