IT. Expert System.

Android Reference

DateFormat


android.text.format

Class DateFormat



  • public class DateFormat
    extends Object
    Utility class for producing strings with formatted date/time.

    Most callers should avoid supplying their own format strings to this class' format methods and rely on the correctly localized ones supplied by the system. This class' factory methods return appropriately-localized DateFormat instances, suitable for both formatting and parsing dates. For the canonical documentation of format strings, see SimpleDateFormat.

    The format methods in this class takes as inputs a format string and a representation of a date/time. The format string controls how the output is generated. This class only supports a subset of the full Unicode specification. Use SimpleDateFormat if you need more. Formatting characters may be repeated in order to get more detailed representations of that field. For instance, the format character 'M' is used to represent the month. Depending on how many times that character is repeated you get a different representation.

    For the month of September:
    M -> 9
    MM -> 09
    MMM -> Sep
    MMMM -> September

    The effects of the duplication vary depending on the nature of the field. See the notes on the individual field formatters for details. For purely numeric fields such as HOUR adding more copies of the designator will zero-pad the value to that number of characters.

    For 7 minutes past the hour:
    m -> 7
    mm -> 07
    mmm -> 007
    mmmm -> 0007

    Examples for April 6, 1970 at 3:23am:
    "MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
    "MMM dd, yyyy h:mmaa" -> "Apr 6, 1970 3:23am"
    "MMMM dd, yyyy h:mmaa" -> "April 6, 1970 3:23am"
    "E, MMMM dd, yyyy h:mmaa" -> "Mon, April 6, 1970 3:23am&
    "EEEE, MMMM dd, yyyy h:mmaa" -> "Monday, April 6, 1970 3:23am"
    "'Noteworthy day: 'M/d/yy" -> "Noteworthy day: 4/6/70"

    • Field Summary

      Fields
      Modifier and Type Field and Description
      static char AM_PM
      This designator indicates whether the HOUR field is before or after noon.
      static char CAPITAL_AM_PM
      This designator indicates whether the HOUR field is before or after noon.
      static char DATE
      This designator indicates the day of the month.
      static char DAY
      This designator indicates the name of the day of the week.
      static char HOUR
      This designator indicates the hour of the day in 12 hour format.
      static char HOUR_OF_DAY
      This designator indicates the hour of the day in 24 hour format.
      static char MINUTE
      This designator indicates the minute of the hour.
      static char MONTH
      This designator indicates the month of the year.
      static char QUOTE
      Text in the format string that should be copied verbatim rather that interpreted as formatting codes must be surrounded by the QUOTE character.
      static char SECONDS
      This designator indicates the seconds of the minute.
      static char STANDALONE_MONTH
      This designator indicates the standalone month of the year, necessary in some format strings in some languages.
      static char TIME_ZONE
      This designator indicates the offset of the timezone from GMT.
      static char YEAR
      This designator indicates the year.
    • Constructor Summary

      Constructors
      Constructor and Description
      DateFormat()
    • Field Detail

      • QUOTE

        public static final char QUOTE
        Text in the format string that should be copied verbatim rather that interpreted as formatting codes must be surrounded by the QUOTE character. If you need to embed a literal QUOTE character in the output text then use two in a row.
        See Also:
        Constant Field Values
      • AM_PM

        public static final char AM_PM
        This designator indicates whether the HOUR field is before or after noon. The output is lower-case. Examples: a -> a or p aa -> am or pm
        See Also:
        Constant Field Values
      • CAPITAL_AM_PM

        public static final char CAPITAL_AM_PM
        This designator indicates whether the HOUR field is before or after noon. The output is capitalized. Examples: A -> A or P AA -> AM or PM
        See Also:
        Constant Field Values
      • DATE

        public static final char DATE
        This designator indicates the day of the month. Examples for the 9th of the month: d -> 9 dd -> 09
        See Also:
        Constant Field Values
      • DAY

        public static final char DAY
        This designator indicates the name of the day of the week. Examples for Sunday: E -> Sun EEEE -> Sunday
        See Also:
        Constant Field Values
      • HOUR

        public static final char HOUR
        This designator indicates the hour of the day in 12 hour format. Examples for 3pm: h -> 3 hh -> 03
        See Also:
        Constant Field Values
      • HOUR_OF_DAY

        public static final char HOUR_OF_DAY
        This designator indicates the hour of the day in 24 hour format. Example for 3pm: k -> 15 Examples for midnight: k -> 0 kk -> 00
        See Also:
        Constant Field Values
      • MINUTE

        public static final char MINUTE
        This designator indicates the minute of the hour. Examples for 7 minutes past the hour: m -> 7 mm -> 07
        See Also:
        Constant Field Values
      • MONTH

        public static final char MONTH
        This designator indicates the month of the year. See also STANDALONE_MONTH. Examples for September: M -> 9 MM -> 09 MMM -> Sep MMMM -> September
        See Also:
        Constant Field Values
      • STANDALONE_MONTH

        public static final char STANDALONE_MONTH
        This designator indicates the standalone month of the year, necessary in some format strings in some languages. For example, Russian distinguishes between the "June" in "June" and that in "June 2010".
        See Also:
        Constant Field Values
      • SECONDS

        public static final char SECONDS
        This designator indicates the seconds of the minute. Examples for 7 seconds past the minute: s -> 7 ss -> 07
        See Also:
        Constant Field Values
      • TIME_ZONE

        public static final char TIME_ZONE
        This designator indicates the offset of the timezone from GMT. Example for US/Pacific timezone: z -> -0800 zz -> PST
        See Also:
        Constant Field Values
      • YEAR

        public static final char YEAR
        This designator indicates the year. Examples for 2006 y -> 06 yyyy -> 2006
        See Also:
        Constant Field Values
    • Constructor Detail

      • DateFormat

        public DateFormat()
    • Method Detail

      • is24HourFormat

        public static boolean is24HourFormat(Context context)
        Returns true if user preference is set to 24-hour format.
        Parameters:
        context - the context to use for the content resolver
        Returns:
        true if 24 hour time format is selected, false otherwise.
      • getTimeFormat

        public static DateFormat getTimeFormat(Context context)
        Returns a DateFormat object that can format the time according to the current locale and the user's 12-/24-hour clock preference.
        Parameters:
        context - the application context
        Returns:
        the DateFormat object that properly formats the time.
      • getDateFormat

        public static DateFormat getDateFormat(Context context)
        Returns a DateFormat object that can format the date in short form (such as 12/31/1999) according to the current locale and the user's date-order preference.
        Parameters:
        context - the application context
        Returns:
        the DateFormat object that properly formats the date.
      • getDateFormatForSetting

        public static DateFormat getDateFormatForSetting(Context context,
                                         String value)
        Returns a DateFormat object to format the date as if the date format setting were set to value, including null to use the locale's default format.
        Parameters:
        context - the application context
        value - the date format setting string to interpret for the current locale
      • getLongDateFormat

        public static DateFormat getLongDateFormat(Context context)
        Returns a DateFormat object that can format the date in long form (such as December 31, 1999) for the current locale.
        Parameters:
        context - the application context
        Returns:
        the DateFormat object that formats the date in long form.
      • getMediumDateFormat

        public static DateFormat getMediumDateFormat(Context context)
        Returns a DateFormat object that can format the date in medium form (such as Dec. 31, 1999) for the current locale.
        Parameters:
        context - the application context
        Returns:
        the DateFormat object that formats the date in long form.
      • getDateFormatOrder

        public static char[] getDateFormatOrder(Context context)
        Gets the current date format stored as a char array. The array will contain 3 elements (DATE, MONTH, and YEAR) in the order specified by the user's format preference. Note that this order is only appropriate for all-numeric dates; spelled-out (MEDIUM and LONG) dates will generally contain other punctuation, spaces, or words, not just the day, month, and year, and not necessarily in the same order returned here.
      • format

        public static CharSequence format(CharSequence inFormat,
                          long inTimeInMillis)
        Given a format string and a time in milliseconds since Jan 1, 1970 GMT, returns a CharSequence containing the requested date.
        Parameters:
        inFormat - the format string, as described in DateFormat
        inTimeInMillis - in milliseconds since Jan 1, 1970 GMT
        Returns:
        a CharSequence containing the requested text
      • format

        public static CharSequence format(CharSequence inFormat,
                          Date inDate)
        Given a format string and a Date object, returns a CharSequence containing the requested date.
        Parameters:
        inFormat - the format string, as described in DateFormat
        inDate - the date to format
        Returns:
        a CharSequence containing the requested text
      • hasSeconds

        public static boolean hasSeconds(CharSequence inFormat)
        Indicates whether the specified format string contains seconds. Always returns false if the input format is null.
        Parameters:
        inFormat - the format string, as described in DateFormat
        Returns:
        true if the format string contains SECONDS, false otherwise
      • format

        public static CharSequence format(CharSequence inFormat,
                          Calendar inDate)
        Given a format string and a Calendar object, returns a CharSequence containing the requested date.
        Parameters:
        inFormat - the format string, as described in DateFormat
        inDate - the date to format
        Returns:
        a CharSequence containing the requested text


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 322 / 158766220. Delta: 0.08016 с