Here you can find the source of getDate(Cursor cursor, String columnName)
public static Date getDate(Cursor cursor, String columnName)
//package com.java2s; //License from project: Apache License import android.database.Cursor; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static Date getDate(Cursor cursor, String columnName) { String dateString = cursor.getString(cursor .getColumnIndex(columnName)); if (dateString == null) { return null; }// w w w . j a v a 2 s .co m DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH); Date date = null; try { date = format.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return date; } }