Java中ChronoPeriod接口的getChronology()方法用於獲取此Period的時間順序,這是ISO日曆係統。
用法:
ChronoPeriod getChronology()
參數:此方法不接受任何參數。
返回值:此方法返回此字符串表示形式
以下示例程序旨在說明上述方法:
程序1:
// Java code to show the getChronology() function
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.ChronoUnit;
public class ChronoPeriodClass {
// Function to negate given periods
static void printChronology(ChronoPeriod p1)
{
System.out.println(p1.getChronology());
}
// Driver Code
public static void main(String[] args)
{
// Defining period
int year = 4;
int months = 11;
int days = 10;
ChronoPeriod p1 = Period.of(year, months, days);
printChronology(p1);
}
}
輸出:
ISO
程序2:
// Java code to show the getChronology() function
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.ChronoUnit;
public class ChronoPeriodClass {
// Function to negate given periods
static void printChronology(ChronoPeriod p1)
{
System.out.println(p1.getChronology());
}
// Driver Code
public static void main(String[] args)
{
// Defining period
int year = -4;
int months = -11;
int days = -10;
ChronoPeriod p1 = Period.of(year, months, days);
printChronology(p1);
}
}
輸出:
ISO
參考: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoPeriod.html#getChronology–
相關用法
- Java ChronoZonedDateTime getChronology()用法及代碼示例
- Java ChronoLocalDate getChronology()用法及代碼示例
- Java ChronoLocalDateTime getChronology()用法及代碼示例
- Java ChronoPeriod between()用法及代碼示例
- Java ChronoPeriod plus()用法及代碼示例
- Java ChronoPeriod get()用法及代碼示例
- Java ChronoPeriod isZero()用法及代碼示例
- Java ChronoPeriod addTo()用法及代碼示例
- Java ChronoPeriod subtractFrom()用法及代碼示例
- Java ChronoPeriod minus()用法及代碼示例
- Java ChronoPeriod getUnits()用法及代碼示例
- Java ChronoPeriod isNegative()用法及代碼示例
- Java ChronoPeriod toString()用法及代碼示例
- Java ChronoPeriod hashCode()用法及代碼示例
- Java ChronoPeriod negated()用法及代碼示例
注:本文由純淨天空篩選整理自srinam大神的英文原創作品 ChronoPeriod getChronology() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。