blarouche
asked on
Find a future date
Hi Experts
I would like to find what will be the date for the current year on March first - 5 days.
I would like to get this date as an int this format : example 20070220.
How would I do that ?
Thank you
I would like to find what will be the date for the current year on March first - 5 days.
I would like to get this date as an int this format : example 20070220.
How would I do that ?
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
int date = Integer.parseInt(df.format (cal.getTi me()));
ASKER
Sorry CEHJ
I accepted the answer but I found out an error
My result give me 200611359 which is wrong
I accepted the answer but I found out an error
My result give me 200611359 which is wrong
ASKER
I think there is a mistake in the code.
I changed it for :
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.FEBRUARY);
cal.set(Calendar.DATE,cal. getActualM aximum(Cal endar.MONT H));
cal.add(Calendar.DATE, -4);
DateFormat df = new SimpleDateFormat("yyyymmDD ");
int date = Integer.parseInt(df.format (cal.getTi me()));
System.out.println(date);
But it still doesn't work
I changed it for :
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.FEBRUARY);
cal.set(Calendar.DATE,cal.
cal.add(Calendar.DATE, -4);
DateFormat df = new SimpleDateFormat("yyyymmDD
int date = Integer.parseInt(df.format
System.out.println(date);
But it still doesn't work
ASKER
I found something that works for me.
Calendar cal = Calendar.getInstance();
cal.set(Calendar.MONTH, Calendar.MARCH);
cal.set(Calendar.DATE, 01);
cal.add(Calendar.DATE, -5);
Date myDate = cal.getTime();
DateFormat df = new SimpleDateFormat("yyyyMMdd
int marchdate = Integer.parseInt(df.format
System.out.println(marchda
Yes that's better actually
int date = Integer.parseInt(df.format