The SEToLocaleHandler interface
When using the SELibraryManager to add the ECMA_DATE library to your context, you can specify a SEToLocaleHandler object for that library. When the toLocaleString method of the Date object is invoked from your script, the library will check for the presence of a SEToLocaleHandler object. If you have specified one, that object’s toLocale method will be used to determine the locale string.
The SEToLocaleHandler interface defines a single method:
public boolean toLocale(SEContext se,
StringBuffer buffer,
char type,
double milli_since_1970);
This method is expected to be able to take the milliseconds since Jan 1, 1970 and convert it to locale time. The type parameter determines whether the locale time should be determined for just the date (‘d’), just the time (‘t’), or both (‘b’). The converted locale time should then be placed into the provided buffer. If this method returns false, then the contents of the buffer will be ignored and the result of the toLocaleString function will be bad date.
Once you have an object that implements the SEToLocaleHanlder interface, you can specify it when you add the Date library using the SELibraryManager:
SELibraryManager.addStandardLibraries(se, SELibraryManager.ECMA_DATE, myToLocaleHandler);
or:
SELibraryManager.addStandardLibraries(se, SELibraryManager.ECMA_ALL, myToLocaleHandler);
If you specify a SEToLocaleHandler object when adding one of the other libraries (like the ECMA Math library), the SEToLocaleHandler will be ignored.