java.time.chrono.MinguoDate类的plus()方法用于在将一定数量的临时访问器单元与当前Minguo日期相加后,获取Minguo日期。
用法:
public MinguoDate plus(long amount, TemporalUnit unit)
参数:此方法将以下参数作为参数:
- amount:这是将与当前Minguo日期相加的时间单位的数量。
- unit:这是时间单位或计时单位的对象。
返回值:此方法在将一定数量的临时访问者单位与当前Minguo日期相加后返回Minguo日期。
下面的示例说明了plus()方法:
范例1:
Java
// Java program to demonstrate
// plus() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// creating and initializing
// MinguoDate Object
MinguoDate hidate
= MinguoDate.of(1345, 06, 23);
// display the result
System.out.println("old Minguo date:"
+ hidate);
// adding some amount in Minguo date
// by using minus() method
MinguoDate newdate
= hidate.plus(
22,
ChronoUnit.DAYS);
// display the result
System.out.println("new Minguo date:"
+ newdate);
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:"
+ e);
}
}
}
输出:
old Minguo date:Minguo ROC 1345-06-23 new Minguo date:Minguo ROC 1345-07-15
范例2:
Java
// Java program to demonstrate
// plus() method
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv)
{
try {
// creating and initializing
// MinguoDate Object
MinguoDate hidate
= MinguoDate.of(1345, 06, 23);
// display the result
System.out.println("old Minguo date:"
+ hidate);
// adding some amount in Minguo date
// by using minus() method
MinguoDate newdate
= hidate.plus(
4,
ChronoUnit.DECADES);
// display the result
System.out.println("new Minguo date:"
+ newdate);
}
catch (DateTimeException e) {
System.out.println("passed parameter can"
+ " not form a date");
System.out.println("Exception thrown:"
+ e);
}
}
}
输出:
old Minguo date:Minguo ROC 1345-06-23 new Minguo date:Minguo ROC 1385-06-23
相关用法
- Java MinguoDate minus(long, TemporalUnit)用法及代码示例
- Java MinguoDate now()用法及代码示例
- Java MinguoDate of(int, int, int)用法及代码示例
- Java MinguoDate from()用法及代码示例
- Java MinguoDate getLong()用法及代码示例
- Java MinguoDate toString()用法及代码示例
- Java MinguoDate hashCode()用法及代码示例
- Java MinguoDate lengthOfMonth()用法及代码示例
- Java MinguoDate toEpochDay()用法及代码示例
- Java MinguoDate range()用法及代码示例
- Java MinguoDate equals()用法及代码示例
- Java MinguoDate getEra()用法及代码示例
- Java MinguoDate getChronology()用法及代码示例
- Java MinguoDate atTime()用法及代码示例
- Java MinguoDate now(ZoneId)用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 MinguoDate plus(long, TemporalUnit) method in Java with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。