Java LocalDate類| minusWeeks()方法與示例

LocalDate類minusWeeks()方法 (LocalDate Class minusWeeks() method)

  • minusWeeks() method is available in java.time package.

    minusWeeks()方法在java.time包中可用。

  • minusWeeks() method is used to subtract the given weeks from this LocalDate and return the LocalDate.

    minusWeeks()方法用于從此LocalDate中減去給定的星期并返回LocalDate。

  • minusWeeks() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    minusWeeks()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • minusWeeks() method may throw an exception at the time of performing subtraction.

    minusWeeks()方法在執行減法時可能會引發異常。

    DateTimeException: This exception may throw when the calculated result value exceeds the limit.

    DateTimeException :當計算結果值超出限制時,可能引發此異常。

Syntax:

句法:

    public LocalDate minusWeeks(long weeks_val);

Parameter(s):

參數:

  • long weeks_val – represents the weeks to be subtracted from this LocalDate.

    long week_val –表示要從此LocalDate中減去的周數。

Return value:

返回值:

The return type of this method is LocalDate, it returns the LocalDate that holds the value subtracted the given weeks from this LocalDate.

此方法的返回類型為LocalDate ,它返回LocalDate,該LocalDate保留從此LocalDate中減去給定周數的值。

Example:

例:

// Java program to demonstrate the example 
// of minusWeeks(long weeks_val) method 
// of LocalDate
import java.time.*;
public class MinusWeeksOfLocalDate {
public static void main(String args[]) {
long weeks = 3;
// Instantiates two LocalDate
LocalDate l_da1 = LocalDate.parse("2007-04-04");
LocalDate l_da2 = LocalDate.of(2008, Month.FEBRUARY, 06);
// Display l_da1,l_da2 and weeks
System.out.println("LocalDate l_da1, l_da2: ");
System.out.println("l_da1: " + l_da1);
System.out.println("l_da2: " + l_da2);
System.out.println("weeks to subtract: " + weeks);
System.out.println();
// Here, this method subtracts the
// given weeks from this date l_da1
// i.e. here we are subtracting 3
// weeks from the date l_da1
LocalDate minus_weeks = l_da1.minusWeeks(weeks);
// Display minus_weeks
System.out.println("l_da1.minusWeeks(weeks): " + minus_weeks);
// Here, this method subtracts the 
// given weeks from this date l_da2
// i.e. here we are subtracting 3
// weeks from the date l_da2
minus_weeks = l_da2.minusWeeks(weeks);
// Display minus_weeks
System.out.println("l_da2.minusWeeks(weeks): " + minus_weeks);
}
}

Output

輸出量

LocalDate l_da1, l_da2: 
l_da1: 2007-04-04
l_da2: 2008-02-06
weeks to subtract: 3l_da1.minusWeeks(weeks): 2007-03-14
l_da2.minusWeeks(weeks): 2008-01-16

翻譯自: https://www.includehelp.com/java/localdate-minusweeks-method-with-example.aspx

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541851.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541851.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541851.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Android推薦的幾本書

2019獨角獸企業重金招聘Python工程師標準>>> 第一階段 <<第一行代碼Android>><<瘋狂Android>>第二階段 <<Android開發藝術探索>><<Android群英傳>>Android源碼 第三階段 <<Android開發藝術探索>><&…

java數據類型后綴_java基礎知識---基本數據類型

1)四種整數類型(byte、short、int、long)&#xff1a;byte&#xff1a;8 位&#xff0c;用于表示最小數據單位&#xff0c;如文件中數據&#xff0c;-128~127short&#xff1a;16 位&#xff0c;很少用&#xff0c;-32768 ~ 32767int&#xff1a;32 位、最常用&#xff0c;-2^3…

duration java_Java Duration類| minusMillis()方法與示例

duration java持續時間類minusMillis()方法 (Duration Class minusMillis() method) minusMillis() method is available in java.time package. minusMillis()方法在java.time包中可用。 minusMillis() method is used to subtract the given duration in milliseconds from t…

Thread 和 Runnable創建新線程的區別,Runnable可以共享線程類的實例屬性

Thread實現多線程&#xff1a; public class Thread2 extends Thread{ public int i; public void run(){ for(; i < 100 ;i) { System.out.println(getName() " " i); } } public static void main(String[] args){ for (int j 0; j < 100; j) { System…

java編程求最小公約數_java求最大公約數與最小公倍數

public class Gongyueshu{public static void main(String[] args){//從控制臺輸入兩個數據int m Integer.parseInt(args[0]);int n Integer.parseInt(args[1]);int y 1 ;int b 1;if (m > 0 && n >0){//先判定這兩個數是否為倍數關系&#xff0c;如果是則小數…

tdr上升時間什么設定_TDR的完整形式是什么?

tdr上升時間什么設定TDR&#xff1a;時域反射儀/車票寄存收據/定期存款收據 (TDR: Time Domain Reflectometer/ Ticket Deposit Receipt/ Term Deposit Receipt) 1)TDR&#xff1a;時域反射儀 (1) TDR: Time Domain Reflectometer) TDR is an abbreviation of the "Time D…

【java】反射+poi 導出excel

2019獨角獸企業重金招聘Python工程師標準>>> 反射 導出的數組轉變成對象 private static Object expexcelMaptobean(Class<?> cobj,Map<String,String> map,int[] expColums,String[] params) throws InstantiationException, IllegalAccessException…

css設置背景圖片大小_如何使用CSS設置背景圖片大小?

css設置背景圖片大小Introduction: 介紹&#xff1a; As we all know that the images are a very responsive yet very creative way to display your web page or website to the users. The images also play a major role in indulging users to websites or web pages. T…

java gc的特性_Java12新特性 -- 可中斷的G1 Mixed GC

Java 12 中增強了 G1 垃圾收集器關于混合收集集合的處理策略&#xff0c;這節主要介紹在 Java 12 中同時也對 G1垃圾回收器進行了改進&#xff0c;使其能夠在空閑時自動將 Java 堆內存返還給操作系統&#xff0c;這也是 Java 12 中的另外一項重大改進。目前 Java 11 版本中包含…

在Python3中將字符串轉換為字節的最佳方法

To convert a string to bytes, there are more than one way, 要將字符串轉換為字節&#xff0c;有多種方法&#xff0c; Approach 1: use encode() method 方法1&#xff1a;使用encode()方法 test_str "include_help"print(type(test_str))test_bytes test_st…

【Java】PMD規則學習(1) --字符串比較

PMD是一款采用BSD協議發布的Java程序代碼檢查工具。該工具可以做到檢查Java代碼中是否含有未使用的變量、是否含有空的抓取塊、是否含有不必要的對象等。該軟件功能強大&#xff0c;掃描效率高&#xff0c;是Java程序員debug的好幫手。 PMD支持的編輯器包括&#xff1a;JDevelo…

php定義object數據類型,PHP數據類型(4):對象object

//創建一個類class Student{//定義屬性public $name XuGZh;public $age 20;public $sex 男;//定義方法public function getInfo(){//當前對象中訪問自己屬性用偽變量$thisreturn my name:.$this->name..my age:.$this->age..my sex:.$this->sex;}}對象初始化:要創建…

avr計數_使用8位LCD創建計數器| AVR

avr計數This type of counter may be also used in the EVM machines. A counter can be used to count the number of times a button is pressed. It can have many applications. The most widely used counter application is in EVM and also in customer feedback machin…

php將字符變為數字,數字字符怎么轉化為數字 php 怎么將字符轉成數字

java中&#xff0c;String字符串轉化為數字我現在想把一個String字符串轉化為數字&#xff0c; String s"00000123" 我直接使java中String字符串轉化為數字&#xff1a; 轉換為浮點型&#xff1a; 使用Double或者Float的parseDouble或者parseFloat方法進行轉換 Strin…

用U盤作為啟動盤做系統步驟

步驟一&#xff1a;BIOS設置U盤啟動 制作好Win10 U盤系統安裝盤之后&#xff0c;我們需要在電腦的BIOS設置中把第一啟動設備設置為U盤&#xff0c;設置后就可以從我們制作的Win10 U盤系統安裝盤啟動&#xff0c;從而顯示系統安裝界面開始安裝系統。BIOS設置U盤啟動的方法如下&a…

使用tkinter模塊在Python中進行GUI編程

GUI (Graphical User Interface): GUI(圖形用戶界面)&#xff1a; GUI is a simple application which helps the user to interact with the computer or any other electronic device through a graphical icon. This used to perform different tasks on a desktop or lapt…

php輕博客社區視頻教程,輕博客主題 - SEO極致優化的ZBLOG輕博客主題

zblog自適應輕博客主題&#xff0c;簡潔、輕巧、極致優化~QQ群&#xff1a;457320274 (問題反饋以及其他鏈接交換等) 交流社區&#xff1a;https://www.bxiu.net/ (有問題可以求助交流)更新記錄&#xff1a;2021.02.22 v2.8 更新內容&#xff1a;1、新增分類自定義標題&#xf…

Composer學習之————Ubuntu14.04下安裝Composer

下載Composer&#xff1a; curl -sS https://getcomposer.org/installer | php 安裝Composer&#xff1a; /usr/bin/php composer.phar --version 設置全局命令&#xff1a; sudo mv composer.phar /usr/local/bin/composer 查看是否安裝與設置成功&#xff1a; composer -vers…

u盤啟動iso 開源_啟動和維護開源項目

u盤啟動iso 開源Lets talk about how to start an open-source project? The process can be classified as in three phases, 讓我們談談如何啟動一個開源項目&#xff1f; 該過程可以分為三個階段&#xff0c; Individual senses the need of the project: This is the pha…

java如何解決高并發癥,JAVA線上故障緊急處理詳細過程!

鏈接&#xff1a;https://fredal.xin/java-error-check?hmsrtoutiao.io&utm_mediumtoutiao.io&utm_sourcetoutiao.io線上故障主要會包括 CPU、磁盤、內存以及網絡問題&#xff0c;而大多數故障可能會包含不止一個層面的問題&#xff0c;所以進行排查時候盡量四個方面依…