duration java_Java Duration类| 带示例的dividBy()方法

duration java

持续时间类divideBy()方法 (Duration Class dividedBy() method)

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

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

  • dividedBy() method is used to divide this Duration by the given parameter (divisor) (i.e. this Duration / divisor).

    splitBy()方法用于将持续时间除以给定参数(除数)(即,持续时间/除数)。

  • dividedBy() 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.

    splitBy()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • dividedBy() method does not throw an exception at the time of dividing the objects.

    splitBy()方法在分割对象时不会引发异常。

Syntax:

句法:

    public Duration dividedBy(long divsr);

Parameter(s):

参数:

  • long divsr – represents the divisor by which to divide this object.

    long divsr –表示该对象的除数。

Return value:

返回值:

The return type of this method is Duration, it returns Duration and its value is calculated by using (this BigInteger)/ (divsr).

此方法的返回类型为Duration ,它返回Duration,其值是使用(this BigInteger)/(divsr)计算的。

Example:

例:

// Java program to demonstrate the example 
// of dividedBy(long divsr) method of Duration
import java.time.*;
public class DividedByOfDuration {
public static void main(String args[]) {
long divsr = 5;
// Instantiates two Duration  objects
Duration du1 = Duration.ofHours(10);
Duration du2 = Duration.ofMinutes(25);
// Display du1 and du2
System.out.println("du1: " + du1);
System.out.println("du2: " + du2);
System.out.println();
// divides this Duration object(du1)
// by the given value (divsr) 
Duration div_val = du1.dividedBy(divsr);
System.out.println("du1.dividedBy(divsr): " + div_val);
// divides this Duration object(du2)
// by the given value (divsr) 
div_val = du2.dividedBy(divsr);
System.out.println("du2.dividedBy(divsr): " + div_val);
}
}

Output

输出量

du1: PT10H
du2: PT25Mdu1.dividedBy(divsr): PT2H
du2.dividedBy(divsr): PT5M

翻译自: https://www.includehelp.com/java/duration-dividedby-method-with-example.aspx

duration java

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/544856.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

IP子网划分

IP和子网掩码我们都知道,IP是由四段数字组成,在此,我们先来了解一下3类常用的IPA类IP段 0.0.0.0 到127.255.255.255 (0段和127段不使用)B类IP段 128.0.0.0 到191.255.255.255C类IP段 192.0.0.0 到223.255.255.255XP默认分配的子网掩码每段…

Semaphore自白:限流器用我就对了!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)大家好,我是 Semaphore,我的中文名字叫“信号量”,我来自 JUC 家族(java.uti…

机房合作—我是组长

五一期间开始机房合作,到现在一个多星期了。我,蕾蕾,亮亮一组,我担任组长一职。在着手准备项目开始之前,我们听取了各位师父的一些建议,也算是给我们指明一下方向。第一天晚上,我召开了我们项目…

golang的new函数_new()和make()函数以及Golang中的示例

golang的new函数In Golang, to allocate memory, we have two built-in functions new() and make(). 在Golang中,要分配内存,我们有两个内置函数new()和make() 。 1)new()函数 (1) new() function) Memory returned by new() is zeroed. new()返回的内…

Android Activity和Intent机制学习笔记

文章转自:http://www.cnblogs.com/feisky/archive/2010/01/16/1649081.html Activity Android中,Activity是所有程序的根本,所有程序的流程都运行在Activity之中,Activity具有自己的生命周期(见http://www.cnblogs.com…

scala中字符串计数_如何在Scala中创建一系列字符?

scala中字符串计数The range is a set of data from a lower value to a larger value. In Scala, we have an easy method to create a range using to keyword. 范围是从较低值到较大值的一组数据。 在Scala中,我们有一种使用to关键字创建范围的简单方法。 Synta…

多域名解析到同一网站C的php重定向代码

在index.php最前面加上以下代码&#xff1a; <?php if(strpos($_SERVER[HTTP_HOST],afish.cnblogs.com)false){#header(Location: http://afish.cnblogs.com/);echo <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org…

android 中 gravity 和 layout_gravity 的区别

文章转自&#xff1a;http://blog.csdn.net/feng88724/article/details/6333809 在进行UI布局的时候&#xff0c;可能经常会用到 android:gravity 和 android:layout_Gravity 这两个属性。 关于这两个属性的区别&#xff0c;网上已经有很多人进行了说明&#xff0c;这边再简…

线程的故事:我的3位母亲成就了优秀的我!

作者 | 王磊来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;声明&#xff1a;本故事纯属虚构&#xff0c;如果雷同那就是真事了&#xff01;大家好&#xff0c;我是线程&#xff0c;我的…

c ++查找字符串_C ++结构| 查找输出程序| 套装3

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>#pragma pack(1)using namespace std;typedef struct{int A;int B;char c1;char c2;} S;int main(){cout << sizeof(S);return 0;}Output: 输出&#xff1a; In a 32-bit system: 10In a 64-bit sy…

7种内存泄露场景和13种解决方案!

前言Java通过垃圾回收机制&#xff0c;可以自动的管理内存&#xff0c;这对开发人员来说是多么美好的事啊。但垃圾回收器并不是万能的&#xff0c;它能够处理大部分场景下的内存清理、内存泄露以及内存优化。但它也并不是万能的。不然&#xff0c;我们在实践的过程中也不会出现…

Android如何关闭Application

转载自&#xff1a;http://blog.csdn.net/hello_kevinkuang/article/details/7443005 程序启动后&#xff0c;先执行Application.onCreate()&#xff0c;再执行Activity.onCreate()。如果没有生成自己的Application&#xff0c;那么系统会为你自动生成一个。退出程序时我们一般…

Android Sqlite

2019独角兽企业重金招聘Python工程师标准>>> 一、http://lansuiyun.iteye.com/blog/1246430 good! 二、增加新表时&#xff0c;需要更新版本号。 三、Android 使用自定义cursorAdapter&#xff1a; http://blog.csdn.net/buaalei/article/details/6064792 good! 四…

优雅统计代码耗时的4种方法!

来源&#xff1a;jitwxs.cn/5aa91d10.html一、前言代码耗时统计在日常开发中算是一个十分常见的需求&#xff0c;特别是在需要找出代码性能瓶颈时。可能也是受限于 Java 的语言特性&#xff0c;总觉得代码写起来不够优雅&#xff0c;大量的耗时统计代码&#xff0c;干扰了业务逻…

小黑小波比.git clone报错解决方案

2019独角兽企业重金招聘Python工程师标准>>> zmzpzmzp1:~/data$ git clone git192.168.199.199:zmw/s910.git 正克隆到 s910... ssh: connect to host 192.168.199.199 port 22: Connection refused fatal: Could not read from remote repository.Please make sure…

Android 运行时异常 Binary XML file line # : Error inflating class

今天在做一个二维码扫描的项目的时候出现了一个错误&#xff1a; android.view.InflateException: Binary XML file line #12: Error inflating class com.zxing.view.ViewfinderView 项目里面的代码是我从以前项目里面拷贝的&#xff0c;可是各种报错&#xff0c;找了很多资…

一个sql注入直接把我们服务搞挂了

前言最近我在整理安全漏洞相关问题&#xff0c;准备在公司做一次分享。恰好&#xff0c;这段时间团队发现了一个sql注入漏洞&#xff1a;在一个公共的分页功能中&#xff0c;排序字段作为入参&#xff0c;前端页面可以自定义。在分页sql的mybatis mapper.xml中&#xff0c;orde…

reinterpret_cast和static_cast的总结

主要参考&#xff1a;http://blog.csdn.net/querw/article/details/7387594 http://www.cnblogs.com/jerry19880126/archive/2012/08/14/2638192.html http://www.cnblogs.com/ider/archive/2011/07/30/cpp_cast_operator_part3.htmlhttp://bbs.csdn.net/topics/390249118 关键…

Android实现点击两次返回键退出

转自 http://blog.sina.com.cn/s/blog_4fd2a65a0101gg2o.html 在做安卓应用是我们经常要判断用户对返回键的操作&#xff0c;一般为了防止误操作都是在用户连续按下两次返回键的时候提示用户是否退出应用程序。 第一种实现的基本原理就是&#xff0c;当按下BACK键时&#xff0c…

c#hello world_C#| 打印消息/文本(用于打印Hello world的程序)

c#hello worldTo print the message/text or any value – we use two functions: 要打印消息/文本或任何值–我们使用两个功能&#xff1a; Console.Write (); Console.Write(); This function displays text, values on the output device and does not insert a new line …