Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Basically -</p> <ol> <li><p>Create a date format object from the above string</p></li> <li><p>Parse into a date object, and reformat however you prefer.</p></li> </ol> <p>For example (I haven't tested this):</p> <pre><code>/* * REFERENCE: * http://javatechniques.com/blog/dateformat-and-simpledateformat-examples/ */ import java.text.DateFormat; import java.util.Date; public class DateFormatExample1 { public static void main(String[] args) { // Make a new Date object. It will be initialized to the current time. DateFormat dfm = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); Date d = dfm.parse("2011-09-07 00:00:00"); // See what toString() returns System.out.println(" 1. " + d.toString()); // Next, try the default DateFormat System.out.println(" 2. " + DateFormat.getInstance().format(d)); // And the default time and date-time DateFormats System.out.println(" 3. " + DateFormat.getTimeInstance().format(d)); System.out.println(" 4. " + DateFormat.getDateTimeInstance().format(d)); // Next, try the short, medium and long variants of the // default time format System.out.println(" 5. " + DateFormat.getTimeInstance(DateFormat.SHORT).format(d)); System.out.println(" 6. " + DateFormat.getTimeInstance(DateFormat.MEDIUM).format(d)); System.out.println(" 7. " + DateFormat.getTimeInstance(DateFormat.LONG).format(d)); // For the default date-time format, the length of both the // date and time elements can be specified. Here are some examples: System.out.println(" 8. " + DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT).format(d)); System.out.println(" 9. " + DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.SHORT).format(d)); System.out.println("10. " + DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG).format(d)); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload