1, other class API------Date&dateformat

Source: Internet
Author: User

Convert millisecond value to local format

Package Cn.itcast.api.a.date;import Java.text.dateformat;import Java.util.date;public class DateDemo {/** * @param args */public static void Main (string[] args) {Long time = System.currenttimemillis ();//system.out.println (time);// 1382837734218//"How can we turn this time into the familiar time?" "//See also find the date class. Discovery Date Object One initialization can pass a millisecond value. Time = 1382837734218l;//Creates a Date object that encapsulates an existing millisecond value. Gets information about the date object by its method. such as year and month days. Date date = new Date (time); System.out.println (Date.tostring ());//sun Oct 09:35:34 CST 2013//The method of the object is obsolete. International information is obtained through ToString. How to localize information. toLocaleString () is obsolete and is replaced by a lookup information discovery substitution starting with JDK 1.1,//by Dateformat.format (date date). To format a date in a current locale, you can use a static factory method: MyString = Dateformat.getdateinstance (). Format (mydate);//You can define the style when you get the formatter object. Full, LONG, MEDIUM (default style) and Shortdateformat DateFormat = dateformat.getdateinstance (dateformat.full);d Ateformat = Dateformat.getdatetimeinstance (Dateformat.long, Dateformat.long);//The Date object is formatted by calling the Format method. With the default style. String str_date = Dateformat.format (date); System.out.println (str_date);}}

  

1, other class API------Date&dateformat

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.