Java의 국제화
다음 문서에서는 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< locales.length; l++) { String Language = locales[l].getDisplayLanguage(locales[l]); System.out.println(locales[l].toString() + ": " + Language); } } }
Output:
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.
Example #2
Example for the internationalization in Java to show the number in different formats for the different countries.
Code:
// 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 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

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

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

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

Clothoff.io
AI 옷 제거제

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

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

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

뜨거운 주제











Java의 난수 생성기 안내. 여기서는 예제를 통해 Java의 함수와 예제를 통해 두 가지 다른 생성기에 대해 설명합니다.

Java의 Weka 가이드. 여기에서는 소개, weka java 사용 방법, 플랫폼 유형 및 장점을 예제와 함께 설명합니다.

Java의 Smith Number 가이드. 여기서는 정의, Java에서 스미스 번호를 확인하는 방법에 대해 논의합니다. 코드 구현의 예.

이 기사에서는 가장 많이 묻는 Java Spring 면접 질문과 자세한 답변을 보관했습니다. 그래야 면접에 합격할 수 있습니다.

Java 8은 스트림 API를 소개하여 데이터 컬렉션을 처리하는 강력하고 표현적인 방법을 제공합니다. 그러나 스트림을 사용할 때 일반적인 질문은 다음과 같은 것입니다. 기존 루프는 조기 중단 또는 반환을 허용하지만 스트림의 Foreach 메소드는이 방법을 직접 지원하지 않습니다. 이 기사는 이유를 설명하고 스트림 처리 시스템에서 조기 종료를 구현하기위한 대체 방법을 탐색합니다. 추가 읽기 : Java Stream API 개선 스트림 foreach를 이해하십시오 Foreach 메소드는 스트림의 각 요소에서 하나의 작업을 수행하는 터미널 작동입니다. 디자인 의도입니다

Java의 TimeStamp to Date 안내. 여기서는 소개와 예제와 함께 Java에서 타임스탬프를 날짜로 변환하는 방법에 대해서도 설명합니다.

캡슐은 3 차원 기하학적 그림이며, 양쪽 끝에 실린더와 반구로 구성됩니다. 캡슐의 부피는 실린더의 부피와 양쪽 끝에 반구의 부피를 첨가하여 계산할 수 있습니다. 이 튜토리얼은 다른 방법을 사용하여 Java에서 주어진 캡슐의 부피를 계산하는 방법에 대해 논의합니다. 캡슐 볼륨 공식 캡슐 볼륨에 대한 공식은 다음과 같습니다. 캡슐 부피 = 원통형 볼륨 2 반구 볼륨 안에, R : 반구의 반경. H : 실린더의 높이 (반구 제외). 예 1 입력하다 반경 = 5 단위 높이 = 10 단위 산출 볼륨 = 1570.8 입방 단위 설명하다 공식을 사용하여 볼륨 계산 : 부피 = π × r2 × h (4
