cancel
Showing results for 
Search instead for 
Did you mean: 

DatePicker

Former Member
0 Kudos

Hi All,

I am having a webdynpro table which pulls out the KM document name and lastaccessed Date. The lastaccessed date is a "custom property". I have a Date Picker with 2 ui elements:- Start Date and End Date. How can i compare the Start Date and the End Date to this "custom property" to display the documents between that?

Does anyone have code samples for comparing a custom property with the 2 ui elements start date and end date.

Regards,

Divya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

If both the start date and end date is of data type date

Use

Date stDate= // Your context attribute Ex: wdContext.getCurrentContextElemen().getStartDate();

Date endDate= // Your context attribute Ex: wdContext.getCurrentContextElemen().getEndDate();

stDate.compareTo(endDate)

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

Thanx for the reply. That is for Standard Property. But here i want to compare with a Custom property.

if(res.<b>getLastModified().</b>compareTo(Start)>=0)

{

if(res.<b>getLastModified().</b>compareTo(End)<=0)

{

}}

This was possible as getLastModified is a standard property. We have a custom property called "<b>LastAccessedDate</b>". To which we have to compare the Start Date and End Date.

We tried the code

if(res.getProperty(propertyName).compareTo(Start)>=0)

But failed. What is the correct syntax? Could anyone help me out in this issue?

Regards,

Divya

Former Member
0 Kudos

Hi,

Can you explain the data types of your custom ??????

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

String namespace = " http://sapportals.com/xmlns/cm/acc_stat";

String name = "readbyme";

IPropertyName propertyName = new PropertyName(namespace, name);

IProperty prop = new Property(propertyName,"LastAccessed");

if(prop!=null)

{

prop = res.getProperty(propertyName);

contentElem.setHits(String.valueOf(prop));

}

This is how we are fetching the customproperty "readbyme" data into the tablecolumn "Hits".

But we have a start date and and End Date Ui of type date to be compared to this custom property "LastAccessed". The customproperty "LastAccessed" is of type "Boolean".

How can i compare the boolean type property to the ui type "Date"?

Regards,

Divya

Former Member
0 Kudos

why do you want to compare a boolean with a Date? If the boolean is true is fullfills the requirement then it was last accessed or not?

Former Member
0 Kudos

Hi,

Sorry it was a mistake.

It is of type "TimeStamp". and not "Boolean".

Regards,

Divya

former_member751941
Active Contributor
0 Kudos

Hi Divya,

<b>res.getLastModified()</b> this method returns long value.

You cann't apply <b>compareTo</b> on it.

Try this.

long lng = res.getLastModified();

java.sql.Date lastDt = new java.sql.Date(lng);

if(lastDt.compareTo(Start)>=0)

{

}

if(lastDt.compareTo(End)<=0)

{

}

Regards,

Mithu

Former Member
0 Kudos

You could do timesomething like this, where LastAccessedDate is your TimeStamp property:

Date lastAccessed = new Date(LastAccessedDate.getTime());

if(lastAccessed.compareTo(Start)>=0)

{

//do stuff

} else if(lastAccessed compareTo(End)<=0)

{

//do stuff

}

Former Member
0 Kudos

Hi,

Use the long getTime() method of the time stamp

create an Date instance public Date(long date)

and compare the values

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Timestamp.html

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html#Date(long)

Regards

Ayyapparaj

Answers (0)