cancel
Showing results for 
Search instead for 
Did you mean: 

Past Date check

Former Member
0 Kudos

All,

Im checking whether the entered date is in Past or not with below code: The issue is, If i give current date also its giving me an error. If i give future date then no error.

But I want to send an error message only if the date is in past...Is the below code is correct? If not pls correct me..


Date theDate = (Date)
	wdContext.currentContextElement().getAttributeValue("fld");
	IWDAttributeInfo attributeInfo =
	wdContext.getNodeInfo().getAttribute("fld");
	
	if (theDate.before(new Date(System.currentTimeMillis()))) {

//Throw an error message	

	}

Thanks

BM

View Entire Topic
Former Member
0 Kudos

Hi Bharathi M

You can simply use this type of code

if (<b>theDate</b>.after(new Date(System.currentTimeMillis())))

{

..........

}

<b>theDate</b> is what you provide for checking

Check out for this Link you will have a clear idea

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20jav...

Regards,

Mathan MP

Former Member
0 Kudos

All,

I need to send an error message only if the date is in Past..

if (theDate.after(new Date(System.currentTimeMillis()))) is not working as i expected.

BM

Former Member
0 Kudos

Hi,

inputDate.<b>before</b>(CurrDate) //means the date has to be earlier then todays date and future date. If it is equal to todays date that means it is not before current date it is equal.

Same way goes for <b>after</b>.

So their is no inbuilt method that can check if input date is past/future including current date.

If you application needs then you have to code it u r self as explained in my above reply.