java.time.chrono.ThaiBuddhistDate类的minus()方法用于在从当前ThaiBuddhist日期减去一定数量的临时访问器单元后获取ThaiBuddhist日期。
用法:
public ThaiBuddhistDate minus( long amountToSubtract, TemporalUnit unit)
参数:此方法将以下参数作为参数:
- amountToSubstract:这是将从当前ThaiBudhist日期减去的时间单位的值。
- unit:时间单位或计时单位的对象。
返回值:此方法从当前ThaiBuddhist日期中减去一定数量的临时访问器单元后,返回ThaiBuddhist日期。
下面是说明minus()方法的示例:
范例1:
// Java program to demonstrate minus() 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
// ThaiBuddhistDate Object
ThaiBuddhistDate hidate
= ThaiBuddhistDate.now();
// Display the result
System.out.println(
"Old ThaiBuddhist date:"
+ hidate);
// Substracting ThaiBuddhist date
// by using minus() method
ThaiBuddhistDate newdate
= hidate.minus(
22, ChronoUnit.DAYS);
// Display the result
System.out.println(
"New ThaiBuddhist date:"
+ newdate);
}
catch (DateTimeException e) {
System.out.println(
"Passed parameter can"
+ " not form a date");
System.out.println(
"Exception thrown:"
+ e);
}
}
}
输出:
Old ThaiBuddhist date:ThaiBuddhist BE 2563-05-03 New ThaiBuddhist date:ThaiBuddhist BE 2563-04-11
范例2:
// Java program to demonstrate minus() 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
// ThaiBuddhistDate Object
ThaiBuddhistDate hidate
= ThaiBuddhistDate.now();
// Display the result
System.out.println(
"Old ThaiBuddhist date:"
+ hidate);
// Substracting ThaiBuddhist date
// by using minus() method
ThaiBuddhistDate newdate
= hidate.minus(
4, ChronoUnit.DECADES);
// Display the result
System.out.println(
"New ThaiBuddhist date:"
+ newdate);
}
catch (DateTimeException e) {
System.out.println(
"Passed parameter can"
+ " not form a date");
System.out.println(
"Exception thrown:"
+ e);
}
}
}
输出:
Old ThaiBuddhist date:ThaiBuddhist BE 2563-05-03 New ThaiBuddhist date:ThaiBuddhist BE 2523-05-03
相关用法
- Java ThaiBuddhistDate of()用法及代码示例
- Java ThaiBuddhistDate from()用法及代码示例
- Java ThaiBuddhistDate getChronology()用法及代码示例
- Java ThaiBuddhistDate range()用法及代码示例
- Java ThaiBuddhistDate atTime()用法及代码示例
- Java ThaiBuddhistDate equals()用法及代码示例
- Java ThaiBuddhistDate lengthOfMonth()用法及代码示例
- Java ThaiBuddhistDate getEra()用法及代码示例
- Java ThaiBuddhistDate toString()用法及代码示例
- Java ThaiBuddhistDate now(Clock)用法及代码示例
- Java ThaiBuddhistDate getLong()用法及代码示例
- Java ThaiBuddhistDate hashCode()用法及代码示例
- Java ThaiBuddhistDate now(ZoneId)用法及代码示例
- Java Duration from(TemporalUnit)用法及代码示例
- Java JapaneseDate plus(long, TemporalUnit)用法及代码示例
注:本文由纯净天空筛选整理自RohitPrasad3大神的英文原创作品 ThaiBuddhistDate minus(long, TemporalUnit) method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。