Getting custom attributes names via Java API
![](http://jazz.net/_images/myphoto/f4e752cc82358e242b98c2dbd9c9f052.jpg)
Accepted answer
![](http://jazz.net/_images/myphoto/f4e752cc82358e242b98c2dbd9c9f052.jpg)
IAttributeHandle handle = ...
IRepositoryItemService itemService = getService(IRepositoryItemService.class);
IAttribute attribute = (IAttribute) itemService.fetchItem(handle, IRepositoryItemService.COMPLETE);
3 other answers
![](http://jazz.net/_images/myphoto/f4e752cc82358e242b98c2dbd9c9f052.jpg)
The following code snippet should get you started:
com.ibm.team.workitem.common.model.IAttributeHandle handle = workItem.getCustomAttributes().get(0); com.ibm.team.workitem.common.model.IAttribute attribute = (IAttribute) teamRepository.itemManager().fetchCompleteItem(handle, IItemManager.DEFAULT, new NullProgressMonitor());
System.out.println("The attribute id: " + attribute.getIdentifier());
System.out.println("The attribute name: " + attribute.getDisplayName());
System.out.println("The value of the custom attribute: " + workItem.getValue(attribute));
![](http://jazz.net/_images/myphoto/f4e752cc82358e242b98c2dbd9c9f052.jpg)
Problem
The Java code: String str_date = "11-June-13"; DateFormat formatter; Date date =
new Date(); formatter =
new SimpleDateFormat("dd-MMM-yy"); try { date = (Date) formatter.parse(str_date); }
catch (ParseException e) { } java.sql.Timestamp timeStampDate =
new Timestamp(date.getTime()); newWorkItem.setValue(attribute, timeStampDate);
|