SimpleDateFormat
Date--Text
Date now = new Date (); SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd"); String strdate = Sdf.format (now); System.out.println (strdate);
Date now = new Date (); SimpleDateFormat SDF = new SimpleDateFormat ("yyyy mm month DD day"); String strdate = Sdf.format (now); System.out.println (strdate);
Date now = new Date (); SimpleDateFormat SDF = new SimpleDateFormat ("yyyy mm month DD Day HH:mm:ss"); String strdate = Sdf.format (now); System.out.println (strdate);
Text-to-date
Parse from a string into a Date object
SimpleDateFormat SDF = new SimpleDateFormat ("Yyyy-mm-dd"); try{Date date = Sdf.parse ("2018-10-10"); SYSTEM.OUT.PRINTLN (date);} catch (ParseException e) {System.out.println ("Time resolved error:" + e.getmessage ());}
Method
String Format (date date)
Format date as a string formats a date into a date/time string.
Date Parse (String source)
Parse String to date
Parses text from the beginning of the given string to produce a date.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/86/B7/wKiom1fIJxLySxqqAADe9c5j-t4156.png "title=" Date.png "alt=" Wkiom1fijxlysxqqaade9c5j-t4156.png "/>
Java's SimpleDateFormat class