Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Add Future Date in AndroidStudio

String dt = "2012-01-04";  // Start date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
try {
    c.setTime(sdf.parse(dt));
} catch (ParseException e) {
    e.printStackTrace();
}
c.add(Calendar.DATE, 40);  // number of days to add, can also use Calendar.DAY_OF_MONTH in place of Calendar.DATE
SimpleDateFormat sdf1 = new SimpleDateFormat("MM-dd-yyyy");
String output = sdf1.format(c.getTime());
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Add #Future #Date #AndroidStudio
ADD COMMENT
Topic
Name
8+7 =