18
Overview Package Class Use  Tree Deprecated  Index Help  Java TM 2 Platform  Std. Ed. v1.4.2 PREV CLASS NEXT CLASS FRA MES NO FRAMES All Classes SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD  java.text Class DateFormat java.lang.Object  java.text.Format  java.text.DateFormat All Implemented Interfaces: Cloneable, Serializable Direct Known Subclasses: SimpleDateFormat  public abstract class DateFormat extends Format DateFormat is an abstrac t class for date /time formatting s ubclasses whi ch formats and parses dates or time in a languag e-independent manner. The dat e/time formatting subclass, such a s Si mpl eDateFormat, a ll ows for formatting (i.e., date -> text), parsing (text -> date), and normalization. The date is represented as a Date object or as the mil li seconds since Jan uary 1, 1970, 00:00:00 GMT . DateFormat provides many class m ethods for obtaining default date/t ime form atters ba sed on the d efault or a gi ven locale and a number of formatting styles. The formatting styl es include FULL, LONG, MEDIUM, and S HOR T . More detail and examples of using these styles are provided in the method de scripti ons. DateFormat helps you to format and parse dates for any locale. Your code can be completely independent of the locale con ventions for months, days of the week, o r even t he ca lendar format: lunar vs. solar. To format a date for the current Locale, use one of the static factory methods: myString = DateFormat.getDateInstance().format(myDate);  If you are formatting m ultipl e dates, it is more efficient to get the format and u se it multi ple times so that the system doesn't have to fet ch the information about the local language and country c onventions mul tiple tim es. DateFormat df = DateFormat.getDateInstance(); for (int i = 0; i < a.length; ++i) { output.println(df.format(myDate[i]) + "; "); }  T o format a da te for a different Locale, spec ify i t in the c all to getDateInstance(). DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE);  You can use a DateFormat to parse also. DateFormat (Java 2 Platform SE v1.4.2) http: //docs.oracle.com/javase/1.4.2/docs/api/java/text/DateFormat .html 1 dari 18 1/21/2012 12:43 AM

Date Format (Java 2 Platform SE v1.4

Embed Size (px)

Citation preview

Page 1: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 1/18

Page 2: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 2/18

Page 3: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 3/18

Page 4: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 4/18

Page 5: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 5/18

Page 6: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 6/18

Page 7: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 7/18

Page 8: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 8/18

Page 9: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 9/18

Page 10: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 10/18

Page 11: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 11/18

Page 12: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 12/18

Page 13: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 13/18

Page 14: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 14/18

Page 15: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 15/18

Page 16: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 16/18

Page 17: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 17/18

Page 18: Date Format (Java 2 Platform SE v1.4

8/3/2019 Date Format (Java 2 Platform SE v1.4

http://slidepdf.com/reader/full/date-format-java-2-platform-se-v14 18/18