Skip to content

Instantly share code, notes, and snippets.

@GLitchfield
Created January 15, 2014 23:44
Show Gist options
  • Save GLitchfield/8447054 to your computer and use it in GitHub Desktop.
Save GLitchfield/8447054 to your computer and use it in GitHub Desktop.
static final ReadableDateTime dateFromString(final String time) {
MutableDateTime t = new MutableDateTime();
t.setYear(Integer.parseInt(time.subSequence(0,4).toString()));
t.setMonthOfYear(Integer.parseInt(time.subSequence(4,6).toString()));
t.setDayOfMonth(Integer.parseInt(time.subSequence(6,8).toString()));
t.setHourOfDay(Integer.parseInt(time.subSequence(8,10).toString()));
t.setMinuteOfHour(Integer.parseInt(time.subSequence(10, 12).toString()));
t.setSecondOfMinute(Integer.parseInt(time.subSequence(12,14).toString()));
t.setMillisOfSecond(Integer.parseInt(time.subSequence(14,17).toString()));
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment