Fetching Date from Sqlite Database in android

后端 未结 3 1480
青春惊慌失措
青春惊慌失措 2021-02-05 17:05

In my Sqlite DataBase I saved date in a data type DATE. How can i fetch this date from cursor?

3条回答
  •  醉梦人生
    2021-02-05 17:18

    this code works

    String s= cursor.getString(position);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date d=new Date();
        try {
             d=  dateFormat.parse(s);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        YourObject.setDate(d);
    

提交回复
热议问题