Java instance--formatting the current date

Source: Internet
Author: User
Tags dateformat

Technical key: DateFormat class in Java.text Package 1. Get date Formatter public static final DateFormat getdateinstance (int style,locale alocale) This method is used to get the date format objects for the specified style and locale.  Parameter description: ①style: Specifies the format style that the formatter object uses for the date, with the optional values of short (using numbers), long (longer description), and full (complete format). ②alocale: Language Environment object used by the formatter. 2. Date format public final string format (date date) The method formats a Date object as a string in the specified format. Parameter Description: Date: the instance object of the dates class. Implementation process:
1  Packagetest;2 3 ImportJava.text.DateFormat;4 Importjava.util.Date;5 ImportJava.util.Locale;6 7  Public classFormatDate {8 9      Public Static voidMain (string[] args) {Ten         //TODO auto-generated Method Stub OneDate Date =NewDate (); ADateFormat Formater =dateformat.getdateinstance (Dateformat.full, Locale.china); -         //China Date -String string =Formater.format (date); theSYSTEM.OUT.PRINTLN ("China Date: \ t" +string); -         //Canada Date -Formater =dateformat.getdateinstance (Dateformat.full, Locale.canada); -System.out.println ("Canada Date: \ t" +Formater.format (date)); +         //Japan Date -Formater =dateformat.getdateinstance (Dateformat.full, locale.japan); +SYSTEM.OUT.PRINTLN ("Japan Date: \ t" +Formater.format (date)); A         //France Date atFormater =dateformat.getdateinstance (Dateformat.full, locale.france); -SYSTEM.OUT.PRINTLN ("France date: \ t" +Formater.format (date)); -         //Germany Date -Formater =dateformat.getdateinstance (Dateformat.full, Locale.german); -System.out.println ("German date: \ t" +Formater.format (date)); -         //Italy Date inFormater =dateformat.getdateinstance (Dateformat.full, locale.italy); -System.out.println ("Italian date: \ t" +Formater.format (date)); to     } +  -}
The output looks like this:

Java instance--formatting the current date

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.