Search code examples
androiddatabasetimeupdating

How to database.update the date value


I have a date value in this format: yyyy-MM-dd kk:mm:ss

So from this line data = params.getString("data"); i get the date I have set before in another activity. So with a button click I need to add + 10 minutes to the date value.

I do know its through the value.put("...",...); but as I don't want to change the DATE only the TIME of the value. How should do I do it?


Solution

  • Use an instance of Calendar:

     SimpleDateFormat currentDate = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
    
     Calendar c = Calendar.getInstance();
     c.setTime(currentDate.parse(data)); // your date value
     c.add(Calendar.MINUTE,10);
     newDate = c.getTime()