How can I Convert Calendar.toString() into date using SimpleDateFormat.parse()?

Tags: , , ,

I’m developing an Android app that uses a database, every time that the user insert a new register the current data and time is save in the db using

Calendar cal = Calendar.getInstance();

So, When I retrieve the data from the db, got a String like this:


The problem comes when I try convert that String using SimpleDateFormat.parse to display it in a RecyclerView, I get always the same date: 09/04/2017.

This is the code in my

public void onBindViewHolder(ViewHolder holder,int position){

    String s,d,p,f;

    s = items.getString(ConsultaTomas.SISTOLICA);

    d = items.getString(ConsultaTomas.DIASTOLICA);

    p = items.getString(ConsultaTomas.PULSO);

    f = items.getString(ConsultaTomas.FECHA);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

    try {

    }catch (ParseException e){
        Log.d("PARSINGFECHA","Error al parcear fecha");


The other data is showed correctly in the RecView and the Calendar String are all diferent, so there is not the same date/hour in these strings. So, the question is:

How can I Convert Calendar.toString() into date using SimpleDateFormat.parse()?

This is the result running the app in a real device: two muppets


You need to modify the way you store the Calendar, call getTime() and format it as desired to begin with. For example,

Calendar cal = Calendar.getInstance();
DateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

Source: stackoverflow