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.mzph.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;所以进行排查时候尽量四个方面依…