mirror of
https://github.com/quinton-ashley/java2js
synced 2024-12-29 10:11:54 +01:00
19 lines
439 B
JavaScript
Executable File
19 lines
439 B
JavaScript
Executable File
jre.imports['java.util.Formatter'].load = () => {
|
|
|
|
const IllegalFormatException = jre.import('java.util.IllegalFormatException');
|
|
|
|
class Formatter {
|
|
format(format, ...args) {
|
|
let regex = /%[0-9\.]*[\w]/;
|
|
for (let arg of args) {
|
|
if (!regex.test(format)) {
|
|
throw new IllegalFormatException();
|
|
}
|
|
format = format.replace(regex, arg.toString());
|
|
}
|
|
return format;
|
|
}
|
|
}
|
|
jre.java.util.Formatter = Formatter;
|
|
};
|