Skip to content

Instantly share code, notes, and snippets.

@oludouglas
Last active September 6, 2016 08:29
Show Gist options
  • Save oludouglas/71f266530951ba2f1c0a6eff1b881e41 to your computer and use it in GitHub Desktop.
Save oludouglas/71f266530951ba2f1c0a6eff1b881e41 to your computer and use it in GitHub Desktop.
String getTime(String dateString){
Calendar calendar = GregorianCalendar.getInstance();
try {
String newString = null;
if(dateString.contains("+"))
newString = dateString.substring(0, dateString.indexOf("+"));
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:sss");
Date date = format.parse(newString);
calendar.setTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
return String.valueOf(calendar.getTime());
}
@simonorups
Copy link

i will keep that for future use

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment