datetime - How can I convert this string to a standard date in java? -


Earlier I posted the following question:

But now I want to know how I can change it I am starter in date / time.

  2010-03-15T16: 34: 46Z  

For example: 03/15/10

Renewed :

  string pattern = "mm / dd / or" hh: mm "at date date = new date; try {date = new simpledate format (pattern). (Q.getUpdated_at ());} hold (ParseException e) {e.printStackTrace ();} DateText.setText (New SimpleDateFormat ('hh: mma' on 'MM / dd / yy') format (date));  

gives me such a result:

  Mon 15 Mar 16:34:50 MST 2010  

How to do I can format it

  03/15/10 at 4:34 pm  

?

In short, you want to convert the date in a string format to a date in Another string format has you:

  2010-03-15T16: 34: 46Z  

And you want

  03/15 / 10 p.m. 4:34 pm  

You do not end up using the object as a start Want to do You do not want to use its toString () because it definitely gives a certain format

Bozho's answer still applies. Use First of all, you must parse in the string format in the date the date object so that you return it to format in another string format Able to

  // First parse string in pattern "yyyy-MM-dd'THH: mm: ss'Z '" string for date object dateString1 = "2010-03-15T16: 34: 46Z "; Date date = new simpleadformat ("yyy-mm-dd'th: mm: ss's '') .pars (datestring1); // then the date object on the" H: MMA "pattern in" MM / dd / yy " Format. String dateString2 = New SimpleDeformat ("MM / DD / Y" at H: MMA). Format (date); Println (dateString2); // 03/15/10 PM 4:34 PM  

Comments