1
0
mirror of https://github.com/quinton-ashley/java2js synced 2024-12-29 10:11:54 +01:00

18 lines
450 B
JavaScript
Raw Permalink Normal View History

2021-09-24 00:36:29 -05:00
jdk.imports['java.util.Formatter'].load = async () => {
const IllegalFormatException = await jdk.import('java.util.IllegalFormatException');
2021-09-23 01:41:44 -05:00
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;
}
}
2021-09-23 23:26:42 -05:00
jdk.java.util.Formatter = Formatter;
2021-09-23 01:41:44 -05:00
};