Android. Text. format. dateformat

Source: Internet
Author: User
Tags dateformat time in milliseconds

The date and time parsing class, which is located in the package Android. Text. format. dateformat. This class provides three time objects in Java, prompting you to call the following three methods in static mode:

Final Static charsequence format (charsequence hour, date indate) // input a date object
Given a format string and a date object, returns a charsequence containing the requested date.

Final Static charsequence format (charsequence seconds, calendar indate) // Calendar Object
Given a format string and a Calendar Object, returns a charsequence containing the requested date.

Final Static charsequence format (charsequence seconds, long intimeinmillis) // long object
Given a format string and a time in milliseconds since Jan 1, 1970 GMT, returns a charsequence containing the requested date.

We may see that the first parameter is bytes, which is a string type of the charsequence interface. It provides a flexible time format to parse the string description, prompting you to pay attention to Case sensitivity, as shown in figure

In the example of limit L 6, 1970 at AM, the write method of the limit parameter and the final execution result are as follows,

The following uses the cwj birthday of android123 as an example:

"Mm/DD/yy H: MPAA"-> "11/03/87 am"
"Mmm DD, yyyy H: MPAA"-> "Nov 3, 1987 am"
"Mmmm DD, yyyy H: MPAA"-> "November 3, 1987 am"
"E, Mmmm DD, yyyy H: MPAA"-> "Tues, November 3, 1987 am"
"Eeee, Mmmm DD, yyyy H: MPAA"-> "Tues day, Nov 3, 1987 am"


In 24-hour format:


"Eeee, Mmmm DD, yyyy KK: mm"
-> "Tues day,
Nov 3, 1987"


Where: 12-hour: hh; 24-hour: kk


If simpledateformat is used, it is: hh; hh


The static Boolean is24hourformat (context) method of the android. Text. format. dateformat class can be used to determine whether the current system time is in the 24-hour format.



Constants

Public static final char am_pmsince: API level 3

This designator indicates whetherHOURField is before or after noon. The output is lower-case. Examples: A-> A or p aa-> am or PM

Constant Value: 97 (0x00000061)

Public static final char capital_am_pmsince: API level 3

This designator indicates whetherHOURField is before or after noon. The output is capitalized. Examples: A-> A or p aa-> am or PM

Constant Value: 65 (0x00000041)

Public static final char datesince: API level 3

This designator indicates the day of the month. Examples for the 9th of the month: D-> 9 DD-> 09

Constant Value: 100 (0x00000064)

Public static final char daysince: API level 3

This designator indicates the name of the day of the week. Examples for Sunday: E-> sun eeee-> Sunday

Constant Value: 69 (0x00000045)

Public static final char hoursince: API level 3

This designator indicates the hour of the day in 12 hour format. Examples for 3 pm: H-> 3 hh-> 03

Constant Value: 104 (0x00000068)


Public static final char hour_of_daysince: API level 3

This designator indicates the hour of the day in 24 hour format. Example for 3 pm: K-> 15
Examples for midnight: K-> 0 KK-> 00

Constant Value: 107 (0x0000006b)

Public static final char minutesince: API level 3

This designator indicates the minute of the hour. Examples for 7 minutes past the hour: M-> 7mm-> 07

Constant Value: 109 (0x0000006d)

Public static final char monthsince: API level 3

This designator indicates the month of the year examples for September: M-> 9 MM-> 09 mmm-> Sep Mmmm-> September

Constant Value: 77 (0x0000004d)

Public static final char quotesince: API level 3

Text in the format string that shoshould be copied verbatim rather that interpreted as formatting codes must be surrounded byQUOTECharacter. If you need to embed a literalQUOTECharacter
In the output text then use two in a row.

Constant Value: 39 (0x00000027)

Public static final char secondssince: API level 3

This designator indicates the seconds of the minute. Examples for 7 seconds past the minute: S-> 7 SS-> 07

Constant Value: 115 (0x00000073)

Public static final char time_zonesince: API level 3

This designator indicates the offset of the timezone from GMT. Example for US/Pacific timezone: Z->-0800 ZZ-> PST

Constant Value: 122 (0x0000007a)

Public static final char yearsince: API level 3

This designator indicates the year. Examples for 2006 y-> 06 yyyy-> 2006

Constant Value: 121 (0x00000079)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.