X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.trend%2Fexample%2Forg%2Fsimantics%2Ftrend%2FDecimalFormatDemo.java;h=d4c1a7a3726f891f04bfcb6a72d4b31bb848e61e;hb=1efdd1cea0fcef60df0267f23e4ffda9fab5b23d;hp=2a18e39d4592b2dee2cab08d1b15bf9109ff61db;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.trend/example/org/simantics/trend/DecimalFormatDemo.java b/bundles/org.simantics.trend/example/org/simantics/trend/DecimalFormatDemo.java index 2a18e39d4..d4c1a7a37 100644 --- a/bundles/org.simantics.trend/example/org/simantics/trend/DecimalFormatDemo.java +++ b/bundles/org.simantics.trend/example/org/simantics/trend/DecimalFormatDemo.java @@ -1,65 +1,65 @@ -/******************************************************************************* - * Copyright (c) 2007, 2011 Association for Decentralized Information Management in - * Industry THTH ry. - * 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: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.trend; - -import java.util.*; -import java.text.*; - -public class DecimalFormatDemo { - - static public void customFormat(String pattern, double value ) { - DecimalFormat myFormatter = new DecimalFormat(pattern); - String output = myFormatter.format(value); - System.out.println(value + " " + pattern + " " + output); - } - - static public void localizedFormat(String pattern, double value, - Locale loc ) { - NumberFormat nf = NumberFormat.getNumberInstance(loc); - DecimalFormat df = (DecimalFormat)nf; - df.applyPattern(pattern); - String output = df.format(value); - System.out.println(pattern + " " + output + " " + loc.toString()); - } - - static public void main(String[] args) { - - customFormat("###,###.###", 123456.789); - customFormat("###.##", 123456.789); - customFormat("000000.000", 123.78); - customFormat("$###,###.###", 12345.67); - customFormat("\u00a5###,###.###", 12345.67); - - Locale currentLocale = new Locale("en", "US"); - - DecimalFormatSymbols unusualSymbols = - new DecimalFormatSymbols(currentLocale); - unusualSymbols.setDecimalSeparator('|'); - unusualSymbols.setGroupingSeparator('^'); - String strange = "#,##0.###"; - DecimalFormat weirdFormatter = new DecimalFormat(strange, unusualSymbols); - weirdFormatter.setGroupingSize(4); - String bizarre = weirdFormatter.format(12345.678); - System.out.println(bizarre); - - Locale[] locales = { - new Locale("en", "US"), - new Locale("de", "DE"), - new Locale("fr", "FR") - }; - - for (int i = 0; i < locales.length; i++) { - localizedFormat("###,###.###", 123456.789, locales[i]); - } - - } +/******************************************************************************* + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in + * Industry THTH ry. + * 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: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.trend; + +import java.util.*; +import java.text.*; + +public class DecimalFormatDemo { + + static public void customFormat(String pattern, double value ) { + DecimalFormat myFormatter = new DecimalFormat(pattern); + String output = myFormatter.format(value); + System.out.println(value + " " + pattern + " " + output); + } + + static public void localizedFormat(String pattern, double value, + Locale loc ) { + NumberFormat nf = NumberFormat.getNumberInstance(loc); + DecimalFormat df = (DecimalFormat)nf; + df.applyPattern(pattern); + String output = df.format(value); + System.out.println(pattern + " " + output + " " + loc.toString()); + } + + static public void main(String[] args) { + + customFormat("###,###.###", 123456.789); + customFormat("###.##", 123456.789); + customFormat("000000.000", 123.78); + customFormat("$###,###.###", 12345.67); + customFormat("\u00a5###,###.###", 12345.67); + + Locale currentLocale = new Locale("en", "US"); + + DecimalFormatSymbols unusualSymbols = + new DecimalFormatSymbols(currentLocale); + unusualSymbols.setDecimalSeparator('|'); + unusualSymbols.setGroupingSeparator('^'); + String strange = "#,##0.###"; + DecimalFormat weirdFormatter = new DecimalFormat(strange, unusualSymbols); + weirdFormatter.setGroupingSize(4); + String bizarre = weirdFormatter.format(12345.678); + System.out.println(bizarre); + + Locale[] locales = { + new Locale("en", "US"), + new Locale("de", "DE"), + new Locale("fr", "FR") + }; + + for (int i = 0; i < locales.length; i++) { + localizedFormat("###,###.###", 123456.789, locales[i]); + } + + } } \ No newline at end of file