getlong_Java即时类| 带示例的getLong()方法

getlong

即时类getLong()方法 (Instant Class getLong() method)

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

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

  • getLong() method is used to get the value as long for the given temporal field from this Instant.

    getLong()方法用于从此Instant获取给定时间字段的值。

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

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

  • getLong() method may throw an exception at the time of returning value as long.

    只要返回值的时间长, getLong()方法就可能引发异常。

    • DateTimeException: This exception may throw when the given field couldn't be generated.DateTimeException :当无法生成给定字段时,可能引发此异常。
    • UnsupportedTemporalTypeException: This exception may throw when the given field is unsupported.UnsupportedTemporalTypeException :当不支持给定字段时,可能引发此异常。
    • ArithmeticException: This exception may throw when the calculated result exceeds the limit.ArithmeticException :当计算结果超出限制时,可能引发此异常。

Syntax:

句法:

    public long getLong(TemporalField t_field);

Parameter(s):

参数:

  • TemporalField t_field – represents the field of the returned value.

    TemporalField t_field –代表返回值的字段。

Return value:

返回值:

The return type of this method is long, it returns the value of the given field in a long from this Instant.

此方法的返回类型是long ,它从此Instant返回long中给定字段的值。

Example:

例:

// Java program to demonstrate the example 
// of getLong(TemporalField t_field) method 
// of Instant
import java.time.*;
import java.time.temporal.*;
public class GetLongOfInstant {
public static void main(String args[]) {
// Instantiates two Instant
Instant ins1 = Instant.parse("2006-04-03T05:10:15.20Z");
Instant ins2 = Instant.parse("2007-06-05T10:20:30.20Z");
// Display ins1,ins2
System.out.println("Instant ins1 and ins2: ");
System.out.println("ins1: " + ins1);
System.out.println("ins2: " + ins2);
System.out.println();
// Here, this method gets the value of the 
// given field from this Instant i.e.
// here the MICRO_OF_SECOND field value
// will be returned from this Instant ins1
// as long
long get_val = ins1.getLong(ChronoField.MICRO_OF_SECOND);
// Display get_val
System.out.println("ins1.getLong(ChronoField.MICRO_OF_SECOND): " + get_val);
// Here, this method gets the value of the 
// given field from this Instant i.e.
// here the MILLI_OF_SECOND field value
// will be returned from this Instant ins2
// as long
get_val = ins2.getLong(ChronoField.MILLI_OF_SECOND);
// Display get_val
System.out.println("ins2.getLong(ChronoField.MILLI_OF_SECOND): " + get_val);
}
}

Output

输出量

Instant ins1 and ins2: 
ins1: 2006-04-03T05:10:15.200Z
ins2: 2007-06-05T10:20:30.200Zins1.getLong(ChronoField.MICRO_OF_SECOND): 200000
ins2.getLong(ChronoField.MILLI_OF_SECOND): 200

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

getlong

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

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

相关文章

python作品阐述_Python网络编程基础的作品鉴赏-

Python网络编程基础的作品鉴赏Python网络编佳入门图书!175个完整,实践出真知,SocketsDNS、Web Service、FTP、Email、SMTP、POP、IMAP、SocketServe、CGI、XML、Forking、数据库客户端、多线程、异步通信……完整涵盖网络编程的方方面面“这可…

09-梯度运算

梯度运算膨胀操作-腐蚀操作,这里的-操作是图像的减法,可不是简单的加减乘除运算 为了更加形象生动,先将膨胀和腐蚀操作的结果进行合并展示,然后再与梯度运算进行比较 cv2.morphologyEx(pie,cv2.MORPH_GRADIENT,kernel) 第一个参数…

JavaScript学习笔记-我的浅显认识

一:什么是javascript? 它是一种基于对象和事件驱动的解释性的安全的与平台无关的免费的浏览器脚本语言。 二:有什么用途? 使表单的验证放在客户端,更快捷反应,增强网页的交互性。设计一些特效,如菜单&…

典型瀑布模型四个阶段_古典瀑布模型的不同阶段

典型瀑布模型四个阶段The different phases that are included in the classical waterfall model are: 经典瀑布模型包含的不同阶段是: Feasibility study 可行性研究 Requirement analysis and specification 需求分析和规范 Design 设计 Coding and unit testin…

Unity-Shader-渲染队列

Unity-Shader-渲染队列 渲染简介Unity中的几种渲染队列Background (1000)最早被渲染的物体的队列。Geometry (2000) 不透明物体的渲染队列。大多数物体都应该使用该队列进行渲染,也就是Unity Shader中默认的渲染队列。AlphaTest (2450) 有透明通道,需要进…

MyBatis ResultMap(2)

SQL 映射XML 文件是所有sql语句放置的地方。需要定义一个workspace&#xff0c;一般定义为对应的接口类的路径。写好SQL语句映射文件后&#xff0c;需要在MyBAtis配置文件mappers标签中引用&#xff0c;例如&#xff1a; Xml代码 <mappers> <mapper resource&qu…

形态学操作——腐蚀与膨胀

预备知识 结构元&#xff08;SE&#xff09; 1、结构元的中心一般来说是放在其重心位置处&#xff0c;但原则上原点的选择是依赖于你要解决的问题的。 2、对图像操作时&#xff0c;我们要求结构元是矩形阵列。&#xff08;在结构元的基础上添加较少的背景元素实现&#xff09…

java集合转换_java各种集合的转换

内容&#xff1a;1、List转Array 2、Array转List3、String转int[],String[](对单个字符) 4、数组、List、Set、Map相互转换5、一行输入多个元素方法常用集合&#xff1a;Map、Set、List、Array、String1、List转Array&#xff…

10-礼帽与黑帽操作

cv2.morphologyEx(img,cv2.MORPH_TOPHAT,kernel) 第一个参数&#xff1a;图像对象名称 第二个参数&#xff1a;运算类型TOPHAT为礼帽运算 第三个参数&#xff1a;卷积核的大小 礼帽运算&#xff1a;原始的输入-开运算&#xff08;先腐蚀再膨胀&#xff09; 原始带刺儿&#xff…

2011 cnblogs开通--给力吧

在信息传递如此迅速的时代&#xff0c;自己慢慢的老去&#xff0c;是否要想写些什么&#xff0c;跟大家一起分享学习、工作、生活的酸甜苦辣&#xff0c;提高自己的各方面的能力;往后将慢慢记录自己的程序人生吧&#xff0c;就什么多了&#xff0c;作为自己cnblogs第一篇吧^_^转…

Android----获取activity上所有的控件

01/**02 * note 获取该activity所有view03 * author liuh04 * */05 public List<View> getAllChildViews() {06 View view this.getWindow().getDecorView();07 return getAllChildViews(view);08 }09 10 private List<View> …

微信小程序 查找兄弟节点_使用C ++程序在链接列表中查找节点

微信小程序 查找兄弟节点Given a linked list and an integer N, you need to find and return index where N is present in the Linked List. Return -1 if n is not present in the Linked List. 给定一个链表和一个整数N&#xff0c;您需要查找并返回索引&#xff0c;其中链…

形态学操作——开闭运算、顶帽底(黑)帽变换

膨胀和腐蚀运算的问题&#xff1a; 边缘形状发生了变化&#xff0c;膨胀发生了扩张&#xff0c;腐蚀发生了收缩 目标物体变形&#xff0c;对识别时的特征提取会造成影响 解决方法&#xff1a; 开操作: B对A的开操作就是先B对A腐蚀&#xff0c;紧接着用B对结果进行膨胀 先腐…

java 基础实战_Java基础实战(三)

是否是否是否是否获取字符串字符数组大写?小写?数字?非字母与数字大写字母小写字母数字i结束ii1第一步 拆分字符串为字符数组&#xff1a;static void count(String str) {// 将字符串拆分为字符数组char[] charArray str.toCharArray();}第二步 定义相关变量记录结果&…

11-图像梯度-Sobel算子

图像梯度是指图像某像素在x和y两个方向上的变化率&#xff08;与相邻像素比较&#xff09;&#xff0c;是一个二维向量&#xff0c;由2个分量组成&#xff0c;X轴的变化、Y轴的变化 。 其中X轴的变化是指当前像素右侧&#xff08;X加1&#xff09;的像素值减去当前像素左侧&…

给IE有效指定编码

<title>下一站</title> <meta http-equiv"Content-Type" content"text/html; charsetutf-8" /> IE每次打开&#xff0c;均是一片空白&#xff0c;查看右键&#xff0d;编码&#xff0c;显示是GB2312。要手功改为UTF-8后才能正常显示页面…

形态学操作——击中击不中变换

操作目的 HitMiss变换是形态检测的一个工具&#xff0c;通过定义形状模板可以在图像中获取同一形状物体的位置坐标。 算法讲解 1、用击中结构去腐蚀原始图像得到击中结果X&#xff08;这个过程可以理解为在原始图像中寻找和击中结构完全匹配的模块&#xff0c;匹配上了之后&…

stack.pop()方法_C.示例中的Stack.Pop()方法

stack.pop()方法C&#xff03;Stack.Pop()方法 (C# Stack.Pop() method) Stack.Pop() method is used to remove an object from the top of the stack. The method removes and returns the object from the top. Stack.Pop()方法用于从堆栈顶部删除对象。 该方法从顶部删除并…

java list的作用_集合框架(List集合的特有功能概述和测试)

package cn.itcast_03;import java.util.ArrayList;import java.util.List;/** List集合的特有功能&#xff1a;* A:添加功能* void add(int index,Object element):在指定位置添加元素* B:获取功能* Object get(int index):获取指定位置的元素* C:列表迭代器* ListIterator li…

12-图像梯度-Scharr算子和laplacian算子

Scharr算子 cv2.Scharr(img,cv2.CV_64F,1,0) 第一个参数&#xff1a;当前的图像对象名称 第二个参数&#xff1a;当前图像的深度&#xff0c;通常情况下指定为-1&#xff0c;表示输出和输入的深度是一样的&#xff1b;cv2.CV_64F可以存6字节的大小&#xff0c;为了方便后面的取…