Home » Mobile » Android » Android Date functions

Android Date functions

Android most common functions to use for date.

Add Days to Date


public static Date addDaystoDate(Date today,int days)
{

final Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.DAY_OF_MONTH, days);

return c.getTime();

}

Add Hours to Date

public static Date addHourstoDate(Date today,int hours)
{

final Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.HOUR_OF_DAY, hours);
return c.getTime();

}

Add Minutes to Date

public static Date addMinutestoDate(Date today,int minutes)
{

final Calendar c = Calendar.getInstance();
c.setTime(today);
c.add(Calendar.MINUTE, minutes);
return c.getTime();

}

 

 

About

Software Developer in android,java,phone gap,angular js etc interested in challenging work in problem solving.

Leave a Reply