date.gethour_Java LocalDateTime类| 带示例的getHour()方法

date.gethour

LocalDateTime类getHour()方法 (LocalDateTime Class getHour() method)

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

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

  • getHour() method is used to get an hour-of-day field value from this date-time object.

    getHour()方法用于从该日期时间对象获取一天中的小时值。

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

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

  • getHour() method does not throw an exception at the time of getting an hour of the day.

    在一天中的一个小时内, getHour()方法不会引发异常。

Syntax:

句法:

    public int getHour();

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is int, it returns the value hour-of-day field of this object and the number of hours in a day starts from 0 and ends at 23.

此方法的返回类型为int ,它返回此对象的value-of-day字段,并且一天中的小时数从0开始,以23结尾。

Example:

例:

// Java program to demonstrate the example 
// of getHour() method of LocalDateTime
import java.time.*;
public class GetHourOfLocalDateTime {
public static void main(String args[]) {
// Instantiates two LocalDateTime
LocalDateTime da_ti1 = LocalDateTime.parse("2005-10-05T10:10:10");
LocalDateTime da_ti2 = LocalDateTime.now();
// Display da_ti1, da_ti2
System.out.println("LocalDateTime da_ti1 and da_ti2: ");
System.out.println("da_ti1: " + da_ti1);
System.out.println("da_ti2: " + da_ti2);
System.out.println();
// Here, this method returns the
// field value hour-of-day from 
// this date-time object (da_ti1)
int hod = da_ti1.getHour();
// Display hod
System.out.println("da_ti1.getHour(): " + hod);
// Here, this method returns the 
// field value hour-of-day from 
// this date-time object (da_ti2)
hod = da_ti2.getHour();
// Display hod
System.out.println("da_ti2.getHour(): " + hod);
}
}

Output

输出量

LocalDateTime da_ti1 and da_ti2: 
da_ti1: 2005-10-05T10:10:10
da_ti2: 2020-06-05T02:54:33.968481da_ti1.getHour(): 10
da_ti2.getHour(): 2

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

date.gethour

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

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

相关文章

JDBC(Java语言连接数据库)

JDBC(Java语言连接数据库)JDBC本质整体结构基层实现过程(即用记事本而不是idea)第一种实现方式第二种实现方式乐观锁和悲观锁乐观锁悲观锁JDBC本质 整体结构 基层实现过程(即用记事本而不是idea) 第一种实…

那些牛逼的数据分析师,SQL用的到底有多溜

从各大招聘网站中可以看到,今年招聘信息少了很多,但数据分析相关岗位有一定增加,而数据分析能力几乎已成为每个岗位的必备技能。是什么原因让企业如此重视“数据人才”?伴随滴滴出行、智慧营销等的落地商用,部分企业尝…

knn机器学习算法_K-最近邻居(KNN)算法| 机器学习

knn机器学习算法Goal: To classify a query point (with 2 features) using training data of 2 classes using KNN. 目标:使用KNN使用2类的训练数据对查询点(具有2个要素)进行分类。 K最近邻居(KNN) (K- Nearest Neighbor (KNN)) KNN is a basic machine learning…

Linux 指令的分类 (man page 可查看)

man page 常用按键 转载于:https://www.cnblogs.com/aoun/p/4324350.html

google高级搜索命令

一、allintitle:当我们用allintitle提交查询的时候,Google会限制搜索结果仅是那些在网页标题里边包含了我们所有查询关键词的网页。例 [allintitle: detect plagiarism],提交这个查询,Google仅会返回在网页标题里边包含…

Springboot遇到的问题

Springboot遇到的问题1_访问4041.1_url错误1.2_controller和启动项不在同级目录1.3_未加ResponseBody2_字母后端显示大写,传到前端变为小写2.1_Data注释问题1_访问404 1.1_url错误 1.2_controller和启动项不在同级目录 1.3_未加ResponseBody 在方法上面加&#…

45 张图深度解析 Netty 架构与原理

作为一个学 Java 的,如果没有研究过 Netty,那么你对 Java 语言的使用和理解仅仅停留在表面水平,会点 SSH 写几个 MVC,访问数据库和缓存,这些只是初等 Java 程序员干的事。如果你要进阶,想了解 Java 服务器的…

ajax实现浏览器前进后退-location.hash与模拟iframe

为什么80%的码农都做不了架构师?>>> Aajx实现无数据刷新时,我们会遇到浏览器前进后退失效的问题以及URL不友好的问题。 实现方式有两种 1、支持onhashchange事件的,通过更新和读取location.hash的方式来实现 /* 因为Javascript对…

java环境变量配置以及遇到的一些问题

java环境变量配置以及遇到的一些问题1_下载2_配置环境变量2.1_配置JAVA_HOME2.2_配置CLASS_PATH2.2_配置系统路径PATH3_遇到的问题3.1_输入java -version无效3.2_javac无效1_下载 2_配置环境变量 打开我的电脑,右击空白处点击属性 点击高级系统设置 点击环境变量…

c fputc 函数重写_使用示例的C语言中的fputc()函数

c fputc 函数重写C中的fputc()函数 (fputc() function in C) Prototype: 原型: int fputc(const char ch, FILE *filename);Parameters: 参数: const char ch, FILE *filenameReturn type: int 返回类型: int Use of function: 使用功能&a…

登陆 tomcat manager

想进去很简单 就在tomcat的配置文件 conf/tomcat-user.xml中加入 <role rolename"manager-gui"/><user username"dev" password"dev" roles"manager-gui"/> /* 而<role rolename"manager-gui"/>是指拥…

信息系统状态过程图_操作系统中的增强型过程状态图

信息系统状态过程图The enhanced process state diagram was introduced for maintaining the degree of multiprogramming by the Operating System. The degree of multiprogramming is the maximum number of processes that can be handled by the main memory at a partic…

Java中竟有18种队列?45张图!安排

今天我们来盘点一下Java中的Queue家族&#xff0c;总共涉及到18种Queue。这篇恐怕是市面上最全最细讲解Queue的。本篇主要内容如下&#xff1a;本篇主要内容帮你总结好的阻塞队列&#xff1a;18种Queue总结一、Queue自我介绍 队列原理图1.1 Queue自我介绍hi&#xff0c;大家好&…

ssh框架常见错误与解决方法

1.Class not Found Exception 异常.---->解决方法&#xff1a;在lib中加入两个jar包&#xff08;spring.jar与struts2- spring-plugin-2.1.8.1.jar&#xff09;&#xff1b;2.使用hql语句时出现java.lang.reflect.InvocationTargetException(即使用hql回调函数带参数时) 或…

使用gzip优化web应用(filter实现)

相关知识&#xff1a; gzip是http协议中使用的一种加密算法,客户端向web服务器端发出了请求后&#xff0c;通常情况下服务器端会将页面文件和其他资源&#xff0c;返回到客户端&#xff0c;客户端加载后渲染呈现&#xff0c;这种情况文件一般都比较大&#xff0c;如果开启Gzip …

肯德尔相关性分析_肯德尔的Tau机器学习相关性

肯德尔相关性分析Before we begin I hope you guys have a basic understanding of Pearson’s and Spearmans correlation. As the name suggests this correlation was named after Maurice Kendall in the year 1938. 在开始之前&#xff0c;我希望你们对皮尔逊和斯皮尔曼的…

40 张图带你搞懂 TCP 和 UDP

我们本篇文章的组织脉络如下运输层位于应用层和网络层之间&#xff0c;是 OSI 分层体系中的第四层&#xff0c;同时也是网络体系结构的重要部分。运输层主要负责网络上的端到端通信。运输层为运行在不同主机上的应用程序之间的通信起着至关重要的作用。下面我们就来一起探讨一下…

android手机两种方式获取IP地址

http://www.cnblogs.com/android100/p/Android-get-ip.html 1.使用WIFI 首先设置用户权限 Xml代码 <uses-permission android:name"android.permission.ACCESS_WIFI_STATE"></uses-permission> <uses-permission android:name"android.permi…

进程、线程、多线程相关总结

进程、线程、多线程相关总结 一、说说概念 1、进程&#xff08;process&#xff09; 狭义定义&#xff1a;进程就是一段程序的执行过程。 广义定义&#xff1a;进程是一个程序关于某个数据集合的一次运行。它是操作系统动态执行的基本单元&#xff0c;在传统的操作系统中&#…

z字扫描和光栅扫描的转换_扫描转换计算机图形中的直线

z字扫描和光栅扫描的转换扫描转换直线 (Scan Converting a Straight Line) For the scan conversion of a straight line, we need the two endpoints. In normal life, if we want to draw a line we simply draw it by using a scale or ruler. But we cant draw a line on t…