Java Code Examples for java.util.Locale#ITALIAN
The following examples show how to use
java.util.Locale#ITALIAN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocaleUtil.java From estatio with Apache License 2.0 | 6 votes |
public static Locale deriveLocale(final String atPath) { if(atPath != null) { if(atPath.startsWith("/ITA")) { return Locale.ITALIAN; } if(atPath.startsWith("/FRA")) { return Locale.FRENCH; } if(atPath.startsWith("/BEL")) { return Locale.FRENCH; } if(atPath.startsWith("/SWE")) { return Locale.forLanguageTag("SWE"); } } return Locale.ENGLISH; }
Example 2
Source File: Dates.java From gama with GNU General Public License v3.0 | 6 votes |
static Locale getLocale(final String l) { if (l == null) { return Locale.getDefault(); } final String locale = l.toLowerCase(); switch (locale) { case "us": return Locale.US; case "fr": return Locale.FRANCE; case "en": return Locale.ENGLISH; case "de": return Locale.GERMAN; case "it": return Locale.ITALIAN; case "jp": return Locale.JAPANESE; case "uk": return Locale.UK; default: return new Locale(locale); } }
Example 3
Source File: DaylightSavingTimeExamplesUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException { TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); TimeZone tz = TimeZone.getTimeZone("Europe/Rome"); Calendar cal = Calendar.getInstance(tz, Locale.ITALIAN); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ITALIAN); Date dateBeforeDST = df.parse("2018-03-25 01:55"); prettyPrint(cal.getTimeZone()); cal.setTime(dateBeforeDST); System.out.println("Before DST (00:55 UTC - 01:55 GMT+1) = " + dateBeforeDST); System.out.println("With this Calendar " + (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / (60 * 1000) + " minutes must be added to UTC (GMT TimeZone) to get a correct date for this TimeZone\n"); assertThat(cal.get(Calendar.ZONE_OFFSET)).isEqualTo(3600000); assertThat(cal.get(Calendar.DST_OFFSET)).isEqualTo(0); cal.add(Calendar.MINUTE, 10); Date dateAfterDST = cal.getTime(); System.out.println(" After DST (01:05 UTC - 03:05 GMT+2) = " + dateAfterDST); System.out.println("With this Calendar " + (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / (60 * 1000) + " minutes must be added to UTC (GMT TimeZone) to get a correct date for this TimeZone\n"); assertThat(cal.get(Calendar.DST_OFFSET)).isEqualTo(3600000); assertThat(dateAfterDST).isEqualTo(df.parse("2018-03-25 03:05")); Long deltaBetweenDatesInMillis = dateAfterDST.getTime() - dateBeforeDST.getTime(); Long tenMinutesInMillis = (1000L * 60 * 10); assertThat(deltaBetweenDatesInMillis).isEqualTo(tenMinutesInMillis); }
Example 4
Source File: MBeanFieldGroupTest.java From viritin with Apache License 2.0 | 5 votes |
@Test public void notNullAnnotatedFieldsShouldHaveInterpolatedErrorMessageWithLocale() { Locale locale = Locale.ITALIAN; MBeanFieldGroup fieldGroup = new MBeanFieldGroup<>(Tester.class); Field<?> defaultMessageField = fieldGroup.buildAndBind("defaultMessage"); Field<?> customMessageKeyField = fieldGroup.buildAndBind("customMessageKey"); Field<?> customMessageField = fieldGroup.buildAndBind("customMessage"); withLocale(locale, defaultMessageField, customMessageField, customMessageKeyField); fieldGroup.configureMaddonDefaults(); assertThat(defaultMessageField.getRequiredError(), equalTo("Non deve essere nullo")); assertThat(customMessageKeyField.getRequiredError(), equalTo("Gli indirizzi email devono corrispondere!")); assertThat(customMessageField.getRequiredError(), equalTo("Custom message")); }
Example 5
Source File: RbnfRoundTripTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Perform an exhaustive round-trip test on the Italian spellout rules */ @Test public void TestItalianSpelloutRT() { RuleBasedNumberFormat formatter = new RuleBasedNumberFormat(Locale.ITALIAN, RuleBasedNumberFormat.SPELLOUT); doTest(formatter, -999999, 999999); }
Example 6
Source File: RbnfTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Perform a simple spot check on the Italian spellout rules */ @Test public void TestItalianSpellout() { RuleBasedNumberFormat formatter = new RuleBasedNumberFormat(Locale.ITALIAN, RuleBasedNumberFormat.SPELLOUT); String[][] testData = { { "1", "uno" }, { "15", "quindici" }, { "20", "venti" }, { "23", "venti\u00ADtr\u00E9" }, { "73", "settanta\u00ADtr\u00E9" }, { "88", "ottant\u00ADotto" }, { "100", "cento" }, { "106", "cento\u00ADsei" }, { "108", "cent\u00ADotto" }, { "127", "cento\u00ADventi\u00ADsette" }, { "181", "cent\u00ADottant\u00ADuno" }, { "200", "due\u00ADcento" }, { "579", "cinque\u00ADcento\u00ADsettanta\u00ADnove" }, { "1,000", "mille" }, { "2,000", "due\u00ADmila" }, { "3,004", "tre\u00ADmila\u00ADquattro" }, { "4,567", "quattro\u00ADmila\u00ADcinque\u00ADcento\u00ADsessanta\u00ADsette" }, { "15,943", "quindici\u00ADmila\u00ADnove\u00ADcento\u00ADquaranta\u00ADtr\u00E9" }, { "-36", "meno trenta\u00ADsei" }, { "234.567", "due\u00ADcento\u00ADtrenta\u00ADquattro virgola cinque sei sette" } }; doTest(formatter, testData, true); }
Example 7
Source File: ExampleUnitTest.java From android with MIT License | 5 votes |
@Test public void testStringLocale() throws Exception { Locale[] locales = new Locale[]{ Locale.CANADA, Locale.CANADA_FRENCH, Locale.CHINESE, Locale.ENGLISH, Locale.FRANCE, Locale.GERMAN, Locale.GERMANY, Locale.ITALIAN, Locale.ITALY, Locale.JAPAN, Locale.JAPANESE, Locale.KOREA, Locale.KOREAN, Locale.PRC, Locale.ROOT, Locale.SIMPLIFIED_CHINESE, Locale.TAIWAN, Locale.TRADITIONAL_CHINESE, Locale.UK, Locale.US }; String weightString = null; for (Locale locale : locales) { try { weightString = formatFloatWithOneDot(locale, 55.4f); float weight = Float.parseFloat(weightString); } catch (NumberFormatException e) { System.out.println(locale + ">>>>>" + weightString + ">>>>>>>>>> error"); continue; } System.out.println(locale + ">>>>>" + weightString); } }
Example 8
Source File: MessageCatalog.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 9
Source File: WrapLocale.java From jphp with Apache License 2.0 | 4 votes |
@Signature public static Memory ITALIAN(Environment env, Memory... args) { return new ObjectMemory(new WrapLocale(env, Locale.ITALIAN)); }
Example 10
Source File: DecimalFormatSymbolsTest.java From j2objc with Apache License 2.0 | 4 votes |
/** * @tests serialization/deserialization compatibility. */ public void testSerializationSelf() throws Exception { DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.ITALIAN); SerializationTest.verifySelf(symbols); }
Example 11
Source File: DstHelperPluginTest.java From AndroidAPS with GNU Affero General Public License v3.0 | 4 votes |
@Test public void runTest() throws Exception { AAPSMocker.mockMainApp(); AAPSMocker.mockApplicationContext(); TimeZone tz = TimeZone.getTimeZone("Europe/Rome"); TimeZone.setDefault(tz); Calendar cal = Calendar.getInstance(tz, Locale.ITALIAN); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ITALIAN); Date dateBeforeDST = df.parse("2018-03-25 01:55"); cal.setTime(dateBeforeDST); Assert.assertEquals(false, plugin.wasDST(cal)); Assert.assertEquals(true, plugin.willBeDST(cal)); TimeZone.setDefault(tz); cal = Calendar.getInstance(tz, Locale.ITALIAN); dateBeforeDST = df.parse("2018-03-25 03:05"); cal.setTime(dateBeforeDST); Assert.assertEquals(true, plugin.wasDST(cal)); Assert.assertEquals(false, plugin.willBeDST(cal)); TimeZone.setDefault(tz); cal = Calendar.getInstance(tz, Locale.ITALIAN); dateBeforeDST = df.parse("2018-03-25 02:05"); //Cannot happen!!! cal.setTime(dateBeforeDST); Assert.assertEquals(true, plugin.wasDST(cal)); Assert.assertEquals(false, plugin.willBeDST(cal)); TimeZone.setDefault(tz); cal = Calendar.getInstance(tz, Locale.ITALIAN); dateBeforeDST = df.parse("2018-03-25 05:55"); //Cannot happen!!! cal.setTime(dateBeforeDST); Assert.assertEquals(true, plugin.wasDST(cal)); Assert.assertEquals(false, plugin.willBeDST(cal)); TimeZone.setDefault(tz); cal = Calendar.getInstance(tz, Locale.ITALIAN); dateBeforeDST = df.parse("2018-03-25 06:05"); //Cannot happen!!! cal.setTime(dateBeforeDST); Assert.assertEquals(false, plugin.wasDST(cal)); Assert.assertEquals(false, plugin.willBeDST(cal)); }
Example 12
Source File: MessageCatalog.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 13
Source File: MessageCatalog.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 14
Source File: MessageCatalog.java From hottub with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 15
Source File: MessageCatalog.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 16
Source File: MessageCatalog.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 17
Source File: MessageCatalog.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }
Example 18
Source File: ItalianKeyboard.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
@Override public Locale getLocale() { return Locale.ITALIAN; }
Example 19
Source File: MessageCatalog.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
private Locale getLocale(String localeName) { String language, country; int index; index = localeName.indexOf('_'); if (index == -1) { // // Special case the builtin JDK languages // if (localeName.equals("de")) return Locale.GERMAN; if (localeName.equals("en")) return Locale.ENGLISH; if (localeName.equals("fr")) return Locale.FRENCH; if (localeName.equals("it")) return Locale.ITALIAN; if (localeName.equals("ja")) return Locale.JAPANESE; if (localeName.equals("ko")) return Locale.KOREAN; if (localeName.equals("zh")) return Locale.CHINESE; language = localeName; country = ""; } else { if (localeName.equals("zh_CN")) return Locale.SIMPLIFIED_CHINESE; if (localeName.equals("zh_TW")) return Locale.TRADITIONAL_CHINESE; // // JDK also has constants for countries: en_GB, en_US, en_CA, // fr_FR, fr_CA, de_DE, ja_JP, ko_KR. We don't use those. // language = localeName.substring(0, index); country = localeName.substring(index + 1); } return new Locale(language, country); }