Class MonthNameConverter

  • All Implemented Interfaces:
    ObjectConverter

    public class MonthNameConverter
    extends java.lang.Object
    implements ObjectConverter
    Converter which converts int to month string and converts it back.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.text.DateFormat CONCISE_FORMAT
      0 -> "1", 1 -> "2", ..., 11 -> "12"
      static ConverterContext CONTEXT
      Default ConverterContext for MonthConverter.
      static java.text.DateFormat LONG_FORMAT
      0 -> "January", 1 -> "February", ..., 11 -> "December"
      static java.text.DateFormat MEDIUM_FORMAT
      0 -> "Jan", 1 -> "Feb", ..., 11 -> "Dec"
      static java.text.DateFormat SHORT_FORMAT
      0 -> "01", 1 -> "02", ..., 11 -> "12"
    • Constructor Summary

      Constructors 
      Constructor Description
      MonthNameConverter()
      Creates a new CalendarConverter.
    • Field Detail

      • CONTEXT

        public static ConverterContext CONTEXT
        Default ConverterContext for MonthConverter.
      • CONCISE_FORMAT

        public static final java.text.DateFormat CONCISE_FORMAT
        0 -> "1", 1 -> "2", ..., 11 -> "12"
      • SHORT_FORMAT

        public static final java.text.DateFormat SHORT_FORMAT
        0 -> "01", 1 -> "02", ..., 11 -> "12"
      • MEDIUM_FORMAT

        public static final java.text.DateFormat MEDIUM_FORMAT
        0 -> "Jan", 1 -> "Feb", ..., 11 -> "Dec"
      • LONG_FORMAT

        public static final java.text.DateFormat LONG_FORMAT
        0 -> "January", 1 -> "February", ..., 11 -> "December"
    • Constructor Detail

      • MonthNameConverter

        public MonthNameConverter()
        Creates a new CalendarConverter.
    • Method Detail

      • toString

        public java.lang.String toString​(java.lang.Object object,
                                         ConverterContext context)
        Description copied from interface: ObjectConverter
        Converts from object to String based on current locale.
        Specified by:
        toString in interface ObjectConverter
        Parameters:
        object - object to be converted
        context - converter context to be used
        Returns:
        the String
      • getCalendarByMonth

        protected java.util.Calendar getCalendarByMonth​(int month)
      • supportToString

        public boolean supportToString​(java.lang.Object object,
                                       ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports toString method.
        Specified by:
        supportToString in interface ObjectConverter
        Parameters:
        object - object to be converted
        context - converter context to be used
        Returns:
        true if supports toString
      • fromString

        public java.lang.Object fromString​(java.lang.String string,
                                           ConverterContext context)
        Description copied from interface: ObjectConverter
        Converts from String to an object.
        Specified by:
        fromString in interface ObjectConverter
        Parameters:
        string - the string
        context - context to be converted
        Returns:
        the object converted from string
      • supportFromString

        public boolean supportFromString​(java.lang.String string,
                                         ConverterContext context)
        Description copied from interface: ObjectConverter
        If it supports fromString.
        Specified by:
        supportFromString in interface ObjectConverter
        Parameters:
        string - the string
        context - context to be converted
        Returns:
        true if it supports
      • getDefaultFormat

        public java.text.DateFormat getDefaultFormat()
        Gets default format to format a month.
        Returns:
        DefaultFormat
      • setDefaultFormat

        public void setDefaultFormat​(java.text.DateFormat defaultFormat)
        Sets default format to format a month. Default is MEDIUM_FORMAT.
        Parameters:
        defaultFormat - the default format to format the month.
      • main

        public static void main​(java.lang.String[] args)