KrAzY
asked on
Calculating 7 Days Prior for a known date?
Basically I need to know what the date was 7 days before the date I currently know.
Initially I allow the user to set the Date:
:::
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-y y");
Date currentTime1 = new Date();
String dateString = formatter.format(currentTi me1);
jTextFieldDate.setText(dat eString);
:::
ex. 14-MAR-02
Then the user needs to know what the date was 7 days ago. I need to subtract 7 days from the date they confirm and in that format I have above.
Thanks to all that can help.
Initially I allow the user to set the Date:
:::
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-y
Date currentTime1 = new Date();
String dateString = formatter.format(currentTi
jTextFieldDate.setText(dat
:::
ex. 14-MAR-02
Then the user needs to know what the date was 7 days ago. I need to subtract 7 days from the date they confirm and in that format I have above.
Thanks to all that can help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I keep getting this message:
"ClearPurchasesForm.java": Error #: 300 : class getInstance not found in class java.util.Calendar at line 91, column 39
"ClearPurchasesForm.java":
The code I pasted works perfectly fine. Copy and paste the code I presented. Java as you know is case-sensitive, make sure you are using the right case for everything.
Check your imports. It should include java.util package.
Are you using new by any chance as in
Calendar calendar = new Calendar.getInstance();
that won't work..
I can't think of any other error. If u can paste ur code here.. i might be of some help.
Check your imports. It should include java.util package.
Are you using new by any chance as in
Calendar calendar = new Calendar.getInstance();
that won't work..
I can't think of any other error. If u can paste ur code here.. i might be of some help.
ASKER
Thanks... it was a minor error by me.
Calendar calendar = Calendar.getInstance();
// Get date seven days before current date
calendar.add(Calendar.DATE
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy
Date currentTime1 = calendar.getTime();
String dateString = formatter.format(currentTi
jTextFieldDate.setText(dat