| || |
Get current Date and test if string is within date
I have a dynamic web site that returns a bunch of articles every time we do a search. Each article has a date attached to it. What I need to do is, Get the current date and validate that the Date of the article is not older then 7 days from the current date. I can't seem to find a Function in RTF that returns the Current date or some function to compare date ranges. Anyone work with Dates before and know how to do this?
Re: Get current Date and test if string is within date
You could use:
<font class="small">Code:</font><hr /><pre>
Calendar today = new GregorianCalendar(); //get current date
SimpleDateFormat myDateFormat_DDMMCCYY = new SimpleDateFormat("ddMMyyyy"); //set a format
String todayDateFormatted = myDateFormat_DDMMCCYY.format(today.getTime()); //assign today's formatted date to a string
In this example I capture the current date, and format it how I want it to a string. After that you should be able to compare strings.