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