I want to add days like 30, 60, 90, etc to a date a timestamp like 1642599000000 and want to get the new timestamp. I am using the following code but not working properly. It only works for 30 days only.
Calendar c = Calendar.getInstance();
c.setTimeInMillis(initialTimestamp);
Date date= c.getTime();
Calendar cal = new GregorianCalendar();
cal.setTime(date);
cal.add(Calendar.DAY_OF_MONTH, 60); //Adding 60 days to current timestamp
long newTimestamp = cal.getTime().getTime(); //Required this
use
c.add(Calendar.DATE, 60);insteadDAY_OF_MONTHDAY_OF_MONTHmay be used for fetching number of day in current month (not year, not numer of all days fit into timestamp, which is huge and contains thousands of days)