다음 문서에서는 Java의 국제화에 대한 개요를 제공합니다. 국제화는 애플리케이션을 변경할 필요 없이 여러 국가, 언어 및 통화를 자동으로 지원하는 방식으로 웹 애플리케이션을 만드는 프로세스입니다. I와 N 사이에 18개의 문자가 있기 때문에 I18N이라고도 합니다. 오늘날 소프트웨어나 웹사이트를 디자인할 때 전 세계 시장은 중요한 요소입니다. 글로벌 시장을 위한 소프트웨어 애플리케이션이 계속 확장됨에 따라 기업은 현지 지역 및 언어로 사용자와 소통할 수 있는 제품을 만들어야 합니다.
무료 소프트웨어 개발 과정 시작
웹 개발, 프로그래밍 언어, 소프트웨어 테스팅 등
해외 시장용 소프트웨어를 개발하는 개발자는 각 문화의 관습과 차이점을 알고 있어야 합니다. 언어, 구두점, 통화, 날짜, 시간, 숫자 및 시간대는 모두 차이의 예입니다. 현지화 역시 첫 문자 'L'과 마지막 문자 'N' 사이에 10개의 문자가 있기 때문에 I10N으로 단축됩니다. 현지화는 애플리케이션이 특정 언어와 장소에 맞게 조정될 수 있도록 로캘별 텍스트와 구성 요소를 애플리케이션에 추가하는 프로세스입니다.
Java의 국제화 구문
국제화를 구현하는 데 다음 클래스를 사용할 수 있습니다.
- 로케일
- 숫자형식
- 날짜형식
1. 로케일
Locale 객체는 지리적 위치나 언어를 나타내는 데 사용될 수 있습니다. java.util 패키지에는 Locale 클래스가 포함되어 있습니다.
로케일 클래스 생성자:
Locale l = new Locale(String language);
Locale l = new Locale(String language, String country);
로케일 클래스의 상수:
일부 로캘 상수는 이미 Locale 클래스에 선언되어 있습니다.
이러한 상수는 직접 사용할 수 있으며 아래에는 몇 가지 상수가 나와 있습니다.
- 로케일. 영국
- Locale.ITALY
- Locale.US
로케일 클래스의 기능:
- pubic static Locale getDefault(): 이 메소드는 현재 로케일의 인스턴스를 가져오는 데 사용됩니다.
- public static Locale[] getAvailableLocales(): 이 메소드는 현재 로케일의 배열을 가져오는 데 사용됩니다.
- public String getDisplayLanguage(Locale l): 이 메소드는 전달된 로케일 객체의 언어 이름을 가져오는 데 사용됩니다.
- public String getDisplayVariant(Locale l): 이 메소드는 전달된 로케일 객체의 변형 코드를 가져오는 데 사용됩니다.
- public String getDisplayCountry(Locale l): 이 메소드는 전달된 로케일 객체의 국가 이름을 가져오는 데 사용됩니다.
- public static getISO3Language(): 이 메소드는 로케일의 현재 언어 코드에 대한 3자리 약어를 가져오는 데 사용됩니다.
- public static getISO3Country(): 이 메소드는 로케일의 현재 국가에 대한 3자리 약어를 가져오는 데 사용됩니다.
2. 숫자형식
NumberFormat 클래스를 사용하여 특정 로케일에 따라 숫자 형식을 지정할 수 있습니다. java.Text 패키지에 존재하는 NumberFormat 클래스는 추상 클래스이므로 생성자를 사용하여 객체를 생성할 수 없습니다.
로캘 클래스의 기능:
- public static NumberFormat getInstance(): 이 메소드는 기본 Locale의 객체를 가져오는 데 사용됩니다.
- public static NumberFormat getInstance(Locale l): 이 메소드는 전달된 Locale 객체에 대한 객체를 가져오는 데 사용됩니다.
- public static NumberFormat getCurrencyInstance(): 이 메소드는 특정 통화로 표시할 기본 Locale의 개체를 가져오는 데 사용됩니다.
- 공용 정적 형식(long l):이 메소드는 전달된 숫자를 로케일 객체로 변환하는 데 사용됩니다.
3. 날짜형식
날짜 형식은 지역마다 다르기 때문에 날짜 형식을 국제화합니다. DateFromat 클래스를 사용하여 특정 로케일에 따라 날짜 형식을 지정할 수 있습니다. DateFormat은 java.text 패키지의 추상 클래스입니다.
로케일 클래스의 상수:
일부 DateFormat 상수는 DateFormat 클래스에 이미 선언되어 있습니다.
이러한 상수는 직접 사용할 수 있으며 아래에는 몇 가지 상수가 나와 있습니다.
- DateFormat.LONG
- DateFormat.MINUTE_FIELD
- DateFormat.MINUTE_FIELD
DateFormat 클래스의 기능:
- final String format(Date date): This method converts and returns the specified Date object into a string.
- static final DateFormat getInstance(): This method is used to gets a date-time formatter with a short formatting style for date and time.
- static Locale[] getAvailableLocales(): This method is used to gets an array of present locales.
- static final DateFormat getTimeInstance(): This method is used to gets time formatter with default formatting style for the default locale.
- static final DateFormat getTimeInstance(int style): This method is used to gets time formatter with the specified formatting style for the default locale.
- static final DateFormat getTimeInstance(int style, Locale locale): This method is used to gets time formatter with the specified formatting style for the given locale.
- TimeZone getTimeZone(): This method is used to gets an object of TimeZone for this DateFormat instance.
- static final DateFormat getDateInstance(): This method is used to gets date formatter with default formatting style for the default locale.
- static final DateFormat getDateInstance(int style): This method is used to gets date formatter with the specified formatting style for the default locale.
- static final DateFormat getDateInstance(int style, Locale locale): This method is used to gets date formatter with the specified formatting style for the given locale.
- static final DateFormat getDateTimeInstance(): This method is used to gets date or time formatter with default formatting style for the default locale.
- NumberFormat getNumberFormat(): This method is used to gets an object of NumberFormat for this DateFormat instance.
- Calendar getCalendar(): This method is used to gets an object of the Calendar for this DateFormat instance.
Examples of Internationalization in Java
Given below are the examples mentioned:
Example #1
Example for the internationalization in Java to create different country locale.
Code:
// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.util.Locale; public class ex { public static void main(String[] args) { Locale[] locales = { new Locale("en", "US"), new Locale("it", "IT"), new Locale("es", "ES") }; for (int l=0; l <p><strong>Output:</strong></p> <p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/172500369926024.jpg?x-oss-process=image/resize,p_40" class="lazy" alt="Java의 국제화" ></p> <p>As in the above program, the Locale class objects are created and store in the array. Next, used the for loop to iterate each locale object and display its name and its language, as we can see in the above output.</p> <h4 id="Example">Example #2</h4> <p>Example for the internationalization in Java to show the number in different formats for the different countries.</p> <p><strong>Code:</strong></p> <pre class="brush:php;toolbar:false">// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.util.*; import java.text.*; public class ex { public static void main (String[]args) { double n = 45273.8956; NumberFormat f1 = NumberFormat.getInstance (Locale.US); NumberFormat f2 = NumberFormat.getInstance (Locale.ITALY); NumberFormat f3 = NumberFormat.getInstance (Locale.CHINA); System.out.println ("The number format in US is :" + f1.format (n)); System.out.println ("The number format in ITALY is:" + f2.format (n)); System.out.println ("The number format in CHINA is :" + f3.format (n)); } }
Output:
As in the above program, three different NumberFormat class objects are created using the Locale class. Next, using the format() method of the NumberFormat class, the given number is printing in the specific format of the country, as we can see in the above output.
Example #3
Example for the internationalization in Java to show the date in different formats for the different countries.
Code:
// The program can be tested in Eclipse IDE, JAVA 11 package jex; import java.text.DateFormat; import java.util.Date; import java.util.Locale; public class ex { public static void main (String[]args) { DateFormat d1 = DateFormat.getDateInstance (0, Locale.US); DateFormat d2 = DateFormat.getDateInstance (0, Locale.ITALY); DateFormat d3 = DateFormat.getDateInstance (0, Locale.CHINA); System.out.println ("The date format in US is :" + d1.format (new Date ())); System.out.println ("The date format in ITALY is : " + d2.format (new Date ())); System.out.println ("The date format in CHINA is : " + d3.format (new Date ())); } }
Output:
As in the above program, three different DateFormat class objects are created using the Locale class. Next, using the format() method of the DateFormat class, the return date of the Date() method is printing in the specific format of the country, as we can see in the above output.
Conclusion
Internationalization is also called I18N because there are 18 characters between the letters I and N. It is the process of creating web applications in such a way that they automatically support several countries, languages, and currencies without requiring any changes to the application.
위 내용은 Java의 국제화의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

이 기사에서는 Java 프로젝트 관리, 구축 자동화 및 종속성 해상도에 Maven 및 Gradle을 사용하여 접근 방식과 최적화 전략을 비교합니다.

이 기사에서는 Maven 및 Gradle과 같은 도구를 사용하여 적절한 버전 및 종속성 관리로 사용자 정의 Java 라이브러리 (JAR Files)를 작성하고 사용하는 것에 대해 설명합니다.

이 기사는 카페인 및 구아바 캐시를 사용하여 자바에서 다단계 캐싱을 구현하여 응용 프로그램 성능을 향상시키는 것에 대해 설명합니다. 구성 및 퇴거 정책 관리 Best Pra와 함께 설정, 통합 및 성능 이점을 다룹니다.

이 기사는 캐싱 및 게으른 하중과 같은 고급 기능을 사용하여 객체 관계 매핑에 JPA를 사용하는 것에 대해 설명합니다. 잠재적 인 함정을 강조하면서 성능을 최적화하기위한 설정, 엔티티 매핑 및 모범 사례를 다룹니다. [159 문자]

Java의 클래스 로딩에는 부트 스트랩, 확장 및 응용 프로그램 클래스 로더가있는 계층 적 시스템을 사용하여 클래스로드, 링크 및 초기화 클래스가 포함됩니다. 학부모 위임 모델은 핵심 클래스가 먼저로드되어 사용자 정의 클래스 LOA에 영향을 미치도록합니다.


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

WebStorm Mac 버전
유용한 JavaScript 개발 도구

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

Dreamweaver Mac版
시각적 웹 개발 도구
