It's all about the answers!

Ask a question

how to set current date in timestamp attribute in Java Plain API


guoping chen (191014) | asked Nov 26 '13, 7:47 a.m.
I create a timestamp attribute in task workitem.
Now I want to set current date in timestamp attribute in Java Plain API.
How to program it? have examples?

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Nov 26 '13, 8:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A timestamp Attribute, if you look at the API e.g. IWorkItem.setDueDate() id of type java.sql.Timestamp.
You can use the PDE to look at that type, you can search in search engines how it is used. It boils down to
			Timestamp ts=new Timestamp(new Date().getTime());
			target.setDueDate(ts);

where Date is java.util.Date. There are a few constructors not deprecated, that you can use.

Comments
guoping chen commented Nov 27 '13, 1:08 a.m.

Thanks for your advice.
I search for the SDK. I used the following code. It's ok.

//set now to date
        long now= System.currentTimeMillis();
IAttribute targetdate= workItemCommon.findAttribute(newState.getProjectArea(), "updatedate", monitor);
newState.setValue(targetdate, new Timestamp(now));
By the way, what is the PDE? Could you kindly tell me?How to use it?


Ralph Schoon commented Nov 27 '13, 2:38 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.