How to increase the date by one

I have a date and time in the format yyyy-MM-dd:HH:mmI want to increase ddby one t 2013-10-24:11:20to2013-10-25:11:20

    SimpleDateFormat mSDF = new SimpleDateFormat("yyyy-MM-dd:HH:mm");
    time = mSDF.format(calSet.getTime());//calset in my calendar instance 

I do not know what exactly is my time / date. I only know that I need to increase the date by one for the variabletime

+4
source share
3 answers

Use calendar

Calendar cal=Calendar.getInstance();
cal.setDate(yourdate); // pass parsed Date object
cal.add(Calendar.DATE, 1);
cal.getTime(); // here you will get your date
+9
source

Use the method Calendar add.

    Calendar cal=Calendar.getInstance();
    cal.add(Calendar.DATE, 1);
+4
source

You can also use the method set:

c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH)+1);

Exit:

2012-12-31:10:25
2013-01-01:10:25
+1
source

All Articles