How to divide the date and time from mysql in Android


I getting date from MySql, in the format of "yyyy-mm-dd hh:mm:ss" I just want to split the date and time, show date separately and time also. Time like hh:mm, date like yyyy-mm-dd.

You Can also use StringTokenizer class, it allows you to break string into tokens. You can specify characters that will separate tokens.


String date = "yyyy-mm-dd hh:mm:ss";
StringTokenizer tk = new StringTokenizer(date);

String date = tk.nextToken();  // <---  yyyy-mm-dd
String time = tk.nextToken();  // <---  hh:mm:ss