org.springframework.format.datetime.standard

Class InstantFormatter

  • java.lang.Object
    • org.springframework.format.datetime.standard.InstantFormatter
  • All Implemented Interfaces:
    Formatter<java.time.Instant>, Parser<java.time.Instant>, Printer<java.time.Instant>


    public class InstantFormatter
    extends java.lang.Object
    implements Formatter<java.time.Instant>
    Formatter implementation for a JSR-310 Instant, following JSR-310's parsing rules for an Instant (that is, not using a configurable DateTimeFormatter): accepting the default ISO_INSTANT format as well as RFC_1123_DATE_TIME (which is commonly used for HTTP date header values), as of Spring 4.3.
    Since:
    4.0
    Author:
    Juergen Hoeller
    See Also:
    Instant.parse(java.lang.CharSequence), DateTimeFormatter.ISO_INSTANT, DateTimeFormatter.RFC_1123_DATE_TIME
    • Constructor Summary

      Constructors 
      Constructor and Description
      InstantFormatter() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.time.Instant parse(java.lang.String text, java.util.Locale locale)
      Parse a text String to produce a T.
      java.lang.String print(java.time.Instant object, java.util.Locale locale)
      Print the object of type T for display.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • InstantFormatter

        public InstantFormatter()
    • Method Detail

      • parse

        public java.time.Instant parse(java.lang.String text,
                                       java.util.Locale locale)
                                throws java.text.ParseException
        Description copied from interface: Parser
        Parse a text String to produce a T.
        Specified by:
        parse in interface Parser<java.time.Instant>
        Parameters:
        text - the text string
        locale - the current user locale
        Returns:
        an instance of T
        Throws:
        java.text.ParseException - when a parse exception occurs in a java.text parsing library
      • print

        public java.lang.String print(java.time.Instant object,
                                      java.util.Locale locale)
        Description copied from interface: Printer
        Print the object of type T for display.
        Specified by:
        print in interface Printer<java.time.Instant>
        Parameters:
        object - the instance to print
        locale - the current user locale
        Returns:
        the printed text string