How can I get component created datetime?
One answer
IAuditable provides modified() for the modification date. There is no creation date I could find.
IAuditable can have States (history) you can try to see if there is a state history with differnet modification times and take the first date if so.
Comments
In my case, I want to remember the component created datetime and modified time.
According to the JavaDoc of IAuditable you can use the IAuditable.getPredecessorState() and IAuditable.getMergePredecessorState() State recursively, to find such information.
"IAuditable.getPredecessorState() Returns the primary predecessor state of this auditable item state. The predecessor state is another state of the same audtiable item. When
ITeamRepository.allStates(IItemHandle, IAccessProfile)
is used to retrieve all the known states of the item, the predecessor (and merge predecessor) states of each state can be used to construct the version graph.
A newly-created auditable item may or may not carry predecessor state information. Moreover, predecessor states are only retrieved when history is requested. Clients that want to see these must use
allStates(itemHandle,HISTORY)
in order to get meaningful values that they can depend on. The initial state of an item has no predecessor state."
1 vote
It seems need to do some source test.
I will try it.
Thks a lot.