-2

This is the format i am getting from RSS Feed so how to convert it to date object in android?

2014-02-26T08:27:10.087-05:00
Feb 26 2014 8.27 AM -5.00 GMT
Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • This question does not seem to be a duplicate of given link since it is about the specific ISO-8601 timezone-offset format using a colon. Android does not offer a suitable pattern, and Java only with version 7 or later (pattern symbol XXX). So here string preprocessing is necessary as workaround. – Meno Hochschild Feb 26 '14 at 14:03

1 Answers1

1

It's worth noting that your input strings seems to be really strange when it comes to timezone offset - there shouldn't be the colon. In any case, the right way of dealing with this is to use SimpleDateFormat class:

String input = "2014-02-26T08:27:10.087-0500"
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
Date date = formatter.parse(input);

Have a look at the linked documentation to understand the patterns - then you just need to create patterns matching your input.

Aleks G
  • 56,435
  • 29
  • 168
  • 265