Skip to content

Instantly share code, notes, and snippets.

@stsatlantis
Last active September 12, 2016 14:23
Show Gist options
  • Save stsatlantis/4c4f4811f6f46d223d2d9925eea0e5fc to your computer and use it in GitHub Desktop.
Save stsatlantis/4c4f4811f6f46d223d2d9925eea0e5fc to your computer and use it in GitHub Desktop.
private DateTime getDateTime(String time) {
DateTime result = null;
final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
if (time != null) {
try {
DateTimeFormatter DATETIME_FORMATTER = DateTimeFormat.forPattern(DATE_FORMAT);
DateTimeZone dateTimeZone = DateTimeZone.forID("GMT+0");
DateTime date = DATETIME_FORMATTER.withZone(dateTimeZone).parseDateTime(time);
result = date.toDateTime(DateTimeZone.getDefault());
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment