Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaeubi2018-02-08 06:03:46 -0500
committerLeo Ufimtsev2018-02-12 14:27:42 -0500
commitda784537d1cd1e9a3d177d19e9dc4273f84814eb (patch)
treec8e3d328a2648d48b457ebcb670035b9a85be470 /examples
parenta641c5ea7f382696523d5a123772fa0bb92533de (diff)
downloadeclipse.platform.swt-da784537d1cd1e9a3d177d19e9dc4273f84814eb.tar.gz
eclipse.platform.swt-da784537d1cd1e9a3d177d19e9dc4273f84814eb.tar.xz
eclipse.platform.swt-da784537d1cd1e9a3d177d19e9dc4273f84814eb.zip
Bug 248075 - DateTime does not support localization
Change-Id: Icf7d3a72d33b05e7b1d8f36a3e2d03a542cbb6b5 Signed-off-by: laeubi <laeubi@laeubi-soft.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet370.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet370.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet370.java
new file mode 100644
index 0000000000..e862d186e1
--- /dev/null
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet370.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2018 Lablicate GmbH.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Lablicate GmbH - Snippet for Bug 248075
+ */
+package org.eclipse.swt.snippets;
+
+import java.util.*;
+
+/*
+ * example snippet: DateTime with localization support.
+ *
+ * For a list of all SWT example snippets see
+ * http://www.eclipse.org/swt/snippets/
+ *
+ * @since 3.107
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.widgets.*;
+
+public class Snippet370 {
+
+ public static void main(String[] args) {
+ Display display = new Display();
+ Shell shell = new Shell(display);
+ shell.setLayout(new RowLayout(SWT.VERTICAL));
+ Locale[] locales = Locale.getAvailableLocales();
+ for (Locale locale : locales) {
+ createForLocale(shell, locale);
+ }
+ shell.pack();
+ shell.open();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ }
+
+ private static void createForLocale(Shell shell, Locale locale) {
+ System.setProperty("swt.datetime.locale", locale.toLanguageTag());
+ Composite composite = new Composite(shell, SWT.BORDER);
+ composite.setLayout(new RowLayout(SWT.HORIZONTAL));
+ new Label(composite, SWT.NONE).setText(locale.toLanguageTag());
+ new DateTime(composite, SWT.DROP_DOWN);
+ new DateTime(composite, SWT.TIME);
+ }
+}

Back to the top