What is the difference from Locale.ITALY and Locale.ITALIAN

What is the difference from and ? Where can I find all these differences for other regions? When should I use each? Locale.ITALY Locale.ITALIAN

And is it possible to develop our desired language? How?

+4
source share
4 answers

Locale.ITALIAN sets only Italian, country not specified. Locale.ITALY sets both the Italian language and Italy as a country.

, Locale, . , API DateFormat , Locale, getDateInstance(). , . DateFormat ( JDK, ResourceBundle) . DateFormat it_IT it_US it_UK, DateFormat

+3

JavaDoc:

ITALIAN
Useful constant for language.
ITALY
Useful constant for country.

, .

http://docs.oracle.com/javase/7/docs/api/java/util/Locale.html

.
- .

+1

.

Locale.ITALY //Useful constant for country.

 Locale.ITALIAN //Useful constant for language.

.

Locale

+1

;

Locale= ( + /)

, , .

: (it) (IT), : new Locale( "it", "IT" ). (VA), : new Locale( "it", "VA" ). , : new Locale( "it", "CH" ).

, , Java :

  • , , Java .
  • , , , Java .

Java; .

Locale. , - . Locale.ITALIAN Locale.ITALY new Locale .

Locale

Locale : .

Locale , .

, . Monday , lundi .

, . , , , .

, . , - Locale.CANADA_FRENCH Locale.CANADA_FRENCH , , Locale.CANADA ( ) . . , .

.

package work.basil.example;

import java.time.*;
import java.time.format.*;

import java.util.Locale;

public class TickTock {
    public static void main ( String[] args ) {
        TickTock app = new TickTock();
        app.doIt();
    }

    private void doIt ( ) {

        ZoneId z = ZoneId.of( "America/Montreal" );
        ZonedDateTime zdt = ZonedDateTime.now( z );

        FormatStyle fs = FormatStyle.MEDIUM;

        Locale lCanadaFrench = Locale.CANADA_FRENCH;
        DateTimeFormatter fCanadaFrench = DateTimeFormatter.ofLocalizedDateTime( fs ).withLocale( lCanadaFrench );
        String outputCanadaFrench = zdt.format( fCanadaFrench );

        Locale lCanadaEnglish = Locale.CANADA;
        DateTimeFormatter fCanadaEnglish = DateTimeFormatter.ofLocalizedDateTime( fs ).withLocale( lCanadaEnglish );
        String outputCanadaEnglish = zdt.format( fCanadaEnglish );

        System.out.println( zdt );
        System.out.println( outputCanadaFrench );
        System.out.println( outputCanadaEnglish );

    }
}

Java 11 Zulu Azul Systems, OpenJDK, macOS Mojave.

2019-01-17T17: 36: 10.818469-05: 00 [/]

17 2019 17 36 10

17 2019, 5:36:10

, / , Java . Java. .

, Java, OpenJDK. OpenJDK 8 : Unicode (https://en.wikipedia.org/wiki/Unicode_Consortium), (CLDR), , . OpenJDK 9 (JEP 252), CLDR . .

/ , , , . , ar , ( ar-SA), ( ar-TN) ( ar-MA).

. Java , CLDR .

JavaDoc Locale CLDR.

Locale , . , , . (new Locale) .

, .

Locale locale = new Locale( "it" , "IT" ) ;  // Pass standard code for human language, and standard code for country (cultural norms). 

, . , , , Java.

for ( Locale locale : Locale.getAvailableLocales() ) {
    System.out.println( locale.toString() + "  Name: " + locale.getDisplayName( Locale.US ) );
}
0

All Articles