+ */
+public class DateTime {
+ private static Window window = (Window)JS.getGlobal();
+ private static HTMLDocument document = window.getDocument();
+ private static Date currentDate;
+
+ public static void main(String[] args) {
+ fillLocales();
+ window.setInterval(new TimerHandler() {
+ @Override
+ public void onTimer() {
+ updateCurrentTime();
+ }
+ }, 250);
+ }
+
+ private static void fillLocales() {
+ final HTMLSelectElement localeElem = (HTMLSelectElement)document.getElementById("locale");
+ for (Locale locale : Locale.getAvailableLocales()) {
+ HTMLOptionElement option = (HTMLOptionElement)document.createElement("option");
+ option.setValue(locale.toString());
+ option.setLabel(locale.getDisplayName(Locale.getDefault()));
+ localeElem.getOptions().add(option);
+ }
+ localeElem.addEventListener("change", new EventListener() {
+ @Override public void handleEvent(Event evt) {
+ // Don't do anything
+ }
+ });
+ }
+
+ private static void updateCurrentTime() {
+ setCurrentTime(new Date());
+ }
+
+ private static void setCurrentTime(Date date) {
+ currentDate = date;
+ updateCurrentTimeText();
+ }
+
+ private static void updateCurrentTimeText() {
+ HTMLInputElement timeElem = (HTMLInputElement)document.getElementById("current-time");
+ timeElem.setValue(currentDate.toString());
+ }
+}
diff --git a/teavm-samples/src/main/resources/datetime.html b/teavm-samples/src/main/resources/datetime.html
new file mode 100644
index 000000000..4fb748678
--- /dev/null
+++ b/teavm-samples/src/main/resources/datetime.html
@@ -0,0 +1,42 @@
+
+
+
+ Localized date & time demo application
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file