Java Time related content learning (4) DateFormat

Source: Internet
Author: User
Tags abstract constructor dateformat locale object object string format stringbuffer

This chapter mainly introduces DateFormat.

DateFormat Introduction

The role of DateFormat is to format and parse the date/time. In fact, it is the date formatting tool that helps us format date and then converts date into the string string we want to use

However, the DateFormat format date has limited functionality and is not simpledateformat powerful, but DateFormat is SimpleDateFormat's parent class. Therefore, we first have a general understanding of DateFormat, and then learn SimpleDateFormat.

The role of DateFormat is to format date. It supports formatting styles including full, LONG, MEDIUM and short altogether 4 kinds:

(Dateformat.short)

Full of numbers, as 12.13.52 or 3:30pm

(Dateformat.medium)

Longer, such as the 12, 1952

(Dateformat.long)

Longer, such as January 12, 1952 or 3:30:32pm

(Dateformat.full)

is fully specified, such as Tuesday, April 12, 1952 AD, or 3:30:42pm PST.

The definition of DateFormat is as follows

Public abstract class NumberFormat extends Format {}

function interface of DateFormat

Default constructor DateFormat ()//non-constructor Object clone () Boolean Equals (Object object) AB Stract stringbuffer Format (date date, StringBuffer buffer, fieldposition field) final StringBuffer format (Object object, StringBuffer buffer, fieldposition field) final String format (date date) static locale[] Geta      Vailablelocales () Calendar Getcalendar () final static DateFormat getinstance () final static DateFormat Getdateinstance () Final static dateformat getdateinstance (int style) final static DateFormat getdateinstance ( int style, Locale Locale) final static DateFormat gettimeinstance () final static dateformat gettimeinstance (int st YLE) Final static dateformat gettimeinstance (int style, Locale Locale) final static DateFormat getdatetimeinstance () Final static dateformat getdatetimeinstance (int datestyle, int timestyle) final static DateFormat Getdatetimein Stance (int datestyle, inT Timestyle, Locale Locale) NumberFormat getnumberformat () TimeZone gettimezone () int hashcode () Boolean islenient () Date parse (string string) Abstract date Parse (string string, Parseposition pos              ition) Object parseobject (string string, parseposition position) void Setcalendar (Calendar cal) void Setlenient (boolean value) void Setnumberformat (NumberFormat format) void Settimezone ( TimeZone TimeZone)

Note: DateFormat is an abstract class.

When we get the DateFormat instance through the DateFormat getinstance (), Getdateinstance () and Getdatetimeinstance (), the SimpleDateFormat object is actually returned.

The following function is actually the returned SimpleDateFormat object.

Final static DateFormat getinstance () final static
DateFormat gettimeinstance ()
final static DateFormat gettimeinstance (int style)
final static dateformat gettimeinstance (int style, Locale Locale)
final static DateFormat getdateinstance ()
final static dateformat getdateinstance (int style)
final static DateFormat getdateinstance (int style, Locale Locale)
final static DateFormat getdatetimeinstance ()
final static DateFormat getdatetimeinstance (int datestyle, int timestyle)
final static dateformat getdatetimeinstance (int Datestyle, int timestyle, Locale Locale)

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.