How to format Date (string) Attribute in a customised copy of the "download delegate" ?
We are experimenting with a customised a copy of the OOTB sample file, DefaultModeledAttributesDelegate.java. So far, we have managed to modify this file by following some similar examples from PTC Technical Support, and by combining the information given in the WGM manuals with the steps outlined in TPI 127994 we have found out where to put it on the server, how to compile it, and how to make Windchill use the resulting class file. What we have may not be elegant or efficient, but it is a useful start as it does work !
In our customised file we have a line that retrieves the 'modified on' date and passes it to a string, which in turn gets used as the value of an Attribute that we have already setup as a Custom File Property in our SolidWorks template file(s). This is needed for SolidWorks (which does not get given the Attribute PTC_WM_MODIFIED_ON by the U-WGM), but it is not needed for Pro/E (as it does get given the Attribute PTC_WM_MODIFIED_ON by the ProE-WGM), as discussed in : http://communities.ptc.com/message/181114#181114
Unfortunately the value of the text string attribute that this code creates is not formatted by the global system settings we have set for date display formats (and I'm not very surprised by this). The resulting Attribute does get the right date and time for the file modification, but it is in the wrong date format (ie. it defaults to "yyyy-MM-dd HH:mm:ss.S"). After a bit of hunting in the JavaDoc pages I found two classes that look like they are relevant : WTStandardDateFormat, which in turn has a link to SimpleDateFormat.
Hence my question is can a Java expert tell me how to modify the line of code given above, to make use of SimpleDateFormat to re-format the result from getModifiyStamp, as either "dd-MMM-yyyy HH:mm:ss z" or "dd-MMM-yyyy HH:mm:ss" (both of which are valid formats in SimpleDateFormat), before it is put into the text string ? I am hoping this is trivial for a Java expert,...
...and it is. The answer provided by a colleague was to use the following lines of code in the .java file instead of the one shown above (they do need to be placed in the relevant sections of the java file though...). I have tested it briefly tested, and it appears to work as required :
The next thing I need is some conditional logic to make use of the class EPMWorkspaceHelper.manager.getUpdateCounter to set the value of a Boolean called something like modifiedStatus (true or false) and then convert this into another text string Attribute, called something like SHOW_WM_MODIFIED_LOCALLY, but with the Boolean result turned into a text string taken from a pair of values of our choosing such as "+" and <blank>,or "Yes" and "No", so that this can be shown on a SolidWorks drawing just as PTC_MODIFIED can be shown a Pro/E drawing.
Can anyone help with this ?
Message was edited by: Nick Drought to show the answer provided by a colleague, and the next question.