I have some problem with parse some information from String line. In this example, I would like to work with the line 2011-08-28 19:02:30
.
I have a lot of lines for this template. How to parse this date? Thanks
[47.611910999999999, -122.335178] 6 2011-08-28 19:02:30 I'm at Saigon Vietnamese Restaurant II (1529 6th Ave., at Pine St., Seattle) http://example.com
Thanks all. Here is my solution.
private Date parseDate(String line) {
line = line.replaceAll("\\s+", " ").trim();
String[] masWords = line.split(" ");
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = format.parse(masWords[3] + " " + masWords[4]);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}