ZoneId는 Java의 클래스입니다. Instant와 LocalDateTime 간의 변환에 필요한 규칙을 지정하기 위해 도입된 time 패키지입니다. 이 클래스는 ZoneOffset 클래스의 하위 클래스이며 직렬화 가능 인터페이스를 구현하므로 직렬화 가능합니다. 이 클래스는 UTC/그리니치에서만 오프셋을 저장하는 데 사용되는 특정 형식을 사용합니다. 값 기반 클래스이므로 ID에 민감한 작업을 사용하면 예측할 수 없는 결과가 발생할 수 있습니다. 이 클래스는 모든 현지 날짜-시간에 대해 동일한 오프셋을 사용하는 대부분의 고정 오프셋 ID를 나타냅니다.
무료 소프트웨어 개발 과정 시작
웹 개발, 프로그래밍 언어, 소프트웨어 테스팅 등
Java ZoneId 구문
다음은 Java zoneid의 구문입니다.
구문:
public abstract class ZoneId extends Object implements Serializable
필드: public static final Map
이 지도는 다음과 같습니다.
- 동부: -05:00
- HST: -10:00
- MST: -07:00
- ACT: 호주/다윈
- AET: 호주/시드니
- AGT: 아메리카/아르헨티나/부에노스아이레스
- 예술: 아프리카/카이로
- AST: 미국/앵커리지
- BET: America/Sao_Paulo
- BST: 아시아/다카
- CAT: 아프리카/하라레
- CNT: America/St_Johns
- CST: 미국/시카고
- CTT: 아시아/상하이
- 음식: 아프리카/아디스아바바
- ECT: 유럽/파리
- IET: 아메리카/인디애나/인디애나폴리스
- IST: 아시아/콜카타
- JST: 아시아/도쿄
- MIT:태평양/아피아
- NET: 아시아/예레반
- NST: 태평양/오클랜드
- PLT: 아시아/카라치
- PNT: 아메리카/피닉스
- PRT: 아메리카/푸에르토리코
- PST: 아메리카/로스엔젤레스
- SST: 태평양/과달카날
- VST: 아시아/호치민
Java ZoneId 메서드
Java zoneid의 방법은 다음과 같습니다.
1. 공개 정적 ZoneId systemDefault()
이 함수는 시스템 기본 시간대를 가져오는 데 사용됩니다. 이는 TimeZone.getDefault() 함수를 호출하여 해당 시스템의 기본 시간대에 대한 값을 검색합니다. 즉, 시스템 기본 시간대에 대한 모든 업데이트가 결과에 반영됩니다. 출력은 ZoneID 형식으로 변환됩니다. 이 함수에 의해 발생하는 아래 2가지 예외를 처리해야 합니다.-
- DateTimeException: 이는 변환된 영역 ID의 형식이 잘못되었음을 나타냅니다.
- ZoneRulesException: 이는 변환된 영역 지역 ID를 찾을 수 없음을 나타냅니다
코드:
import java.time.ZoneId; public class Main { public static void main(String[] args) { ZoneId zone = ZoneId.systemDefault(); System.out.println("Output of systemDefault()-" +zone); } }
출력:
2. 공개 정적 Set getAvailableZoneIds()
이 함수는 사용 가능한 모든 지역 기반 ID를 반환하는 데 사용됩니다. 목록은 문자열 집합으로 반환됩니다. 반환된 문자열은 Of(String) 함수를 사용하여 Zone-Id 형식으로 변환될 수 있습니다. Offset-Id는 문자열 집합의 결과에 포함되지 않습니다.
코드:
import java.time.ZoneId; import java.util.*; public class Main { public static void main(String[] args) { Set<string> zoneIds = ZoneId.getAvailableZoneIds(); List<string> zoneList = new ArrayList<string>(zoneIds); Collections.sort(zoneList); for (int i = 0; i <p><strong>출력:</strong></p> <p><img src="/static/imghwm/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/172500421161710.png?x-oss-process=image/resize,p_40" class="lazy" alt="자바 영역 ID" ></p> <h4 id="공개-정적-ZoneId-of-String-zoneId">3. 공개 정적 ZoneId of(String zoneId)</h4> <p>이 함수는 함수에 대한 출력으로 문자열로 전달된 유효한 ID에 대해 ZoneID 또는 ZoneOffset을 반환합니다. ZoneOffset은 문자열의 시작 문자('Z', '+' 또는 '-'인 경우)를 기준으로 반환됩니다. 반환되는 ZoneID는 항상 ZoneRules를 따릅니다. 이 변환은 완전한 구문 분석 알고리즘을 사용하여 수행됩니다. 인수의 형식이 유효하지 않은 경우 DateTimeException이 발생하고, 해당 지역의 경우 ID를 찾을 수 없으면 ZoneRulesException이 발생합니다.</p> <p><strong>코드:</strong></p> <pre class="brush:php;toolbar:false">import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); System.out.println("Output of zoneid obtained using of function: "+ zoneId.normalized()); } }
출력:
4. 공개 정적 ZoneId ofOffset(문자열 접두사, ZoneOffset 오프셋)
이 방법은 접두사와 오프셋이 인수로 전달될 때 ZoneID를 얻는 데 사용됩니다. 접두사가 있고 0이 아닌 오프셋 ID가 있는 영역 ID가 반환됩니다. 이 경우 접두사는 “” ZoneOffset이 반환됩니다.
접두사는 'GMT', 'UTC' 또는 'UT'여야 하며, 그렇지 않으면 메소드에서 IllegalArgumentException이 발생합니다.
코드:
import java.time.*; import java.util.*; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.ofOffset("GMT", ZoneOffset.MAX); System.out.println("OfOffset on ZoneId: " + zoneId); } }
Ouput:
5. public static ZoneId from(TemporalAccessor temporal)
This method is used to convert a TemporalAccessor, an arbitrary set of date and time, object to an instance of ZoneId. This function works in a similar manner to TemporalQueries.zone() that extracts offset base zone id. Thus this method matches the signature of Temporal Query that is being used via ZoneId::from() function.
Code:
import java.time.*; import java.util.*; public class Main { public static void main(String[] args) { ZonedDateTime zoneddatetime = ZonedDateTime.parse("2020-02-25T23:12:31.123+02:00[Europe/Paris]"); ZoneId result = ZoneId.from(zoneddatetime); System.out.println("Zone Id got from "+ "TemporalAccessor object \n" + zoneddatetime + "\nis " + result); } }
Output:
6. public abstract String getId()
This function is used to get a unique time-zone ID for a particular object. The format for an offset-based ID is defined by the getId() method in the Timezone class. The ID given as an output helps to uniquely define the object.
Code:
import java.time.*; import java.util.*; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); System.out.println("Id using getID(): "+ zoneId.getId()); } }
Output:
7. public String getDisplayName(TextStyle style,Locale locale)
This method helps to provide the textual representation of the zone. The style required as well as the locale of the output required is given as arguments. And thus, the suitable textual representation of the time-zone id is given as an output. In case no textual representation is present, a complete ID is returned as an output.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); String result = zoneId.getDisplayName(TextStyle.SHORT, Locale.ENGLISH); System.out.println("Name of ID using getDisplayName(): "+ result); } }
Output:
8. public abstract ZoneRules getRules()
This function is used to retrieve the rules that are applied for the given ID. These rules give an idea about the calculations to be performed as well as the functionality associated with time-zone like finding an offset for an instant. ZoneRulesProvider supplies these rules. An advanced provider can also make a dynamic update to these rules, but the results may change over time in this case. In case no rule is available or the rules of JRE is different from that of time-zone, a call made to this function may lead to ZoneRulesException.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); System.out.println("Rules are: "+ zoneId.getRules()); } }
Output:
9. public ZoneId normalized()
This method is used to check if the given zoneID contains a fixed Offset and if yes, a ZOneOffset equal to that fixed offset is returned; otherwise, this is returned. The returned ID will also have ZoneRules similar to the given offset, but the result we get from the getId() function is different from what we get here.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); System.out.println("Normalized Id: "+ zoneId.normalized()); } }
Output:
10. public boolean equals(Object obj)
This method helps to compare 2 different times ZoneId objects. This method overrides the equals method in the Object class, which is used to compare value stored in 2 objects. Similarly, here the value of these ZoneID is compared to see if 2 objects are equal or not. And, Accordingly, true and false is returned.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); ZoneId zoneId2 = ZoneId.of("Europe/Paris"); System.out.println("Output of Equals: "+ zoneId.equals(zoneId2)); } }
Output:
11. public int hashCode()
This function is used to get the hash code for a particular ZoneID object. This hashcode is returned in int format.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); ZoneId zoneId2 = ZoneId.of("Europe/Paris"); System.out.println("Output of zoneid hashCode: "+ zoneId.hashCode()); System.out.println("Output of zoneid2 hashCode: "+ zoneId2.hashCode()); } }
Output:
12. public String toString()
This function is used to get the string representation of the time -zone ID that is stored in the particular Offset ID. This function overrides the method toString() of Object class.
Code:
import java.time.*; import java.util.*; import java.time.format.TextStyle; public class Main { public static void main(String[] args) { ZoneId zoneId = ZoneId.of("Asia/Calcutta"); ZoneId zoneId2 = ZoneId.of("Europe/Paris"); System.out.println("Output of zoneid toString: "+ zoneId.toString()); System.out.println("Output of zoneid2 toString: "+ zoneId2.toString()); } }
Output:
Conclusion
ZoneID is a serialized class that is used to store the IDs that identify different ZoneRules that the government frequently updates. Thus at the time of serialization, rules are used instead as they contain the entire data set. Also, calling normalized() on ZoneId returns fixed offset ID in the format of ZoneOffset.
위 내용은 자바 영역 ID의 상세 내용입니다. 자세한 내용은 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를 무료로 생성하십시오.

인기 기사

뜨거운 도구

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

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

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

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