Skip to main content
12-Amethyst
July 15, 2024
Solved

windchill official code bug

  • July 15, 2024
  • 1 reply
  • 1868 views

 

 

---

**Issue in `TimelineHistoryHelper.getLatestModifyTimestamp`**

The `Timestamp timestamp = Timestamp.valueOf("0000-00-00 00:00:00.000000000");` line consistently triggers an error.

Code snippet:
```java
protected static Timestamp getLatestModifyTimestamp(Persistable paramPersistable) throws WTException {
Timestamp timestamp = Timestamp.valueOf("0000-00-00 00:00:00.000000000");
ArrayList<LifeCycleManaged> arrayList = new ArrayList();
arrayList.add((LifeCycleManaged) paramPersistable);
HashMap hashMap = LifeCycleHelper.service.getHistoryForIterations(arrayList);
if (!hashMap.isEmpty()) {
ArrayList<LifeCycleHistory> arrayList1 = (ArrayList) hashMap.values().toArray()[0];
for (byte b = 0; b < arrayList1.size(); b++) {
LifeCycleHistory lifeCycleHistory = arrayList1.get(b);
if (lifeCycleHistory.getModifyTimestamp().after(timestamp))
timestamp = lifeCycleHistory.getModifyTimestamp();
}
}
return timestamp;
}
```

**How to resolve the above issue**

 

 

Best answer by HelesicPetr

Hi @TB_10966080 

What Windchill version do you use?

 

In my Windchill the helper does not contains the row with zeros. there is just null

Windchill 12.0.2.0 library

 protected static Timestamp getLatestModifyTimestamp(Persistable var0) throws WTException {
 Timestamp var1 = null;
 ArrayList var2 = new ArrayList();
 var2.add((LifeCycleManaged)var0);
 HashMap var3 = LifeCycleHelper.service.getHistoryForIterations(var2);
 if (!var3.isEmpty()) {
 ArrayList var4 = (ArrayList)var3.values().toArray()[0];

 for(int var5 = 0; var5 < var4.size(); ++var5) {
 LifeCycleHistory var6 = (LifeCycleHistory)var4.get(var5);
 if (var1 == null || var6.getModifyTimestamp().after(var1)) {
 var1 = var6.getModifyTimestamp();
 }
 }
 }

 if (var1 == null) {
 var1 = var0.getPersistInfo().getModifyStamp() != null ? var0.getPersistInfo().getModifyStamp() : var0.getPersistInfo().getCreateStamp();
 }

 return var1;
 }

 So you can copy the class from the WNCWEB.jar 

recompile it

correct it 

remove it from WNCWEB

place your class to the codebase correct place same as it was in the WNCWEB.jar

and everything will work 😄  

PetrH

1 reply

17-Peridot
July 15, 2024

"Today you should not (normally) have a need for a Timestamp object. The java.sql.Timestamp class is long outdated. Once we used it for transferring timestamp values with nanosecond precision to and from SQL databases. Today we use the Instant class for this instead. Instant is one of the classes of java.time, "  

https://stackoverflow.com/questions/49809816/timestamp-valueof-method

 

12-Amethyst
July 16, 2024

no.  bug is in windchill source code.we can't change its code.the version of jdk is 7.

HelesicPetr
22-Sapphire II
22-Sapphire II
July 16, 2024

Hi @TB_10966080 

So what do you need from community if you refuse the help idea from @rleir 

PS> you can change the code, but it is on your own risk. 

PetrH