How can I format string with date: 2015-02-17T12:12:17+01:00
to 17.02.2015, 12:12
? This is possible? I read about SimpleDateFormat, but I don't know How can I write format for this example.
Asked
Active
Viewed 80 times
0

edi233
- 3,511
- 13
- 56
- 97
-
I don't know why Blackbelt marked my question as duplicate NetworkOnMainThread – edi233 Feb 23 '15 at 20:04
-
I think @Blackbelt fumbled a copy/paste here. – Mike M. Feb 23 '15 at 20:04
-
1my mistake, I pressed on the wrong button. It is a duplicate of [this](http://stackoverflow.com/questions/9872419/converting-string-to-date-using-simpledateformat) – Blackbelt Feb 23 '15 at 20:04
-
http://stackoverflow.com/a/2375539/2106820 – Arfan Mirza Feb 23 '15 at 20:07
-
1the pattern you have to use to parse the date is `yyyy-MM-dd'T'HH:mm:ssZ`. the `parse` will return you a Date object that you can use to `format` the date the way you want – Blackbelt Feb 23 '15 at 20:07
1 Answers
2
editedThis is an example of SimpleDateFormat class use..hope this get you to the answer
String date_s = " 2011-01-18 00:00:00.0";
SimpleDateFormat dt = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
Date date = dt.parse(date_s);
SimpleDateFormat dt1 = new SimpleDateFormat(" yyyy-MM-dd'T'HH:mm:ssZ ");
System.out.println(dt1.format(date));

Suraj Palwe
- 2,080
- 3
- 26
- 42