java getmonth_Java LocalDateTime类| 带示例的getMonth()方法

java getmonth

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

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

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

  • getMonth() method is used to get the field value month-of-year based on the enum Month from this date-time object.

    getMonth()方法用于根据此日期时间对象的枚举Month获取年份的月份值。

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

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

  • getMonth() method does not throw an exception at the time of getting the month of the year.

    getMonth()方法在获取一年中的月份时不会引发异常。

Syntax:

句法:

    public Month getMonth();

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is Month, it returns the value of the month-of-year field by using enum Month.

此方法的返回类型为Month ,它通过使用枚举Month返回年份月份字段的值。

Example:

例:

// Java program to demonstrate the example 
// of getMonth() method of LocalDateTime
import java.time.*;
public class GetMonthOfLocalDateTime {
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 month-of-year by using the Month
// enum from this date-time object 
// (da_ti1)
Month get_mon = da_ti1.getMonth();
// Display get_mon
System.out.print("da_ti1.getMonth(): ");
System.out.println(get_mon);
// Here, this method returns the field
// value month-of-year by using the Month
// enum from this date-time object 
// (da_ti2)
get_mon = da_ti2.getMonth();
// Display get_mon
System.out.print("da_ti2.getMonth(): ");
System.out.println(get_mon);
}
}

Output

输出量

LocalDateTime da_ti1 and da_ti2: 
da_ti1: 2005-10-05T10:10:10
da_ti2: 2020-06-06T20:24:48.822267da_ti1.getMonth(): OCTOBER
da_ti2.getMonth(): JUNE

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

java getmonth

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

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

相关文章

阿里最喜欢问的多线程顺序打印的5种解法!

Keeper导读大家在换工作面试中,除了一些常规算法题,还会遇到各种需要手写的题目,所以打算总结出来,给大家个参考。全文 2929 字,剩下的是代码,P6 及以下阅读只需要 8 分钟,高 P 请直接关闭第一篇…

CSS入门

CSS入门1_CSS概要1.1_CSS引入方式2_CSS选择器3_字体样式3.1_字体属性3.2_字体类型:font-family3.3_字体大小:font-size3.4_字体粗细:font-weight3.5_字体颜色:color3.6_总结4_文本样式4.1_文本样式属性4.2_首行缩进:te…

Oracle笔记:数据库启动的三个阶段

数据库的启动可分为三个阶段:1、startup nomount -- 启动实例,不加载数据库 nomount:在这一阶段,只需要读取initSID.ora文件,启动数据库实例,创建后台进程。在initSID.ora文件中,可以定位…

Java LocalDate类| lengthOfYear()方法和示例

LocalDate类lengthOfYear()方法 (LocalDate Class lengthOfYear() method) lengthOfYear() method is available in java.time package. lengthOfYear()方法在java.time包中可用。 lengthOfYear() method is used to get the length of the year represented by this LocalDate…

23张图!万字详解「链表」,从小白到大佬!

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)链表和数组是数据类型中两个重要又常用的基础数据类型。数组是连续存储在内存中的数据结构,因此它的优势是可以通…

何为“秒传”

写在前面 最近一直在弄文件传输的组件,在讨论组里面,有同事提到“秒传”的功能。在目前的通信软件中也有网盘的功能,就从网上搜了一下,这里对“秒传”的实现思路做一下总结,在之后会写一个小的demo实现一下。没有其他&…

JavaScript入门

JavaScript入门1_语法基础1.1_变量1.2_数据类型1.3_运算符1.4_类型转换1.5_注释跟c一样2_流程控制语句3_函数3.1_没有返回值的函数3.2_有返回值的函数4_对象4.1_对象简介4.2_字符串对象4.3_数组对象4.4_时间对象4.5_数学对象简介5_DOM基础5.1_DOM是什么5.2_节点类型5.3_获取元素…

oracle 序列的概念与使用步骤

转载自:http://www.worlduc.com/blog2012.aspx?bid20342458 一、概念 1、 序列: 是oacle提供的用于产生一系列唯一数字的数据库对象。主要用于提供主键值。 2、 创建序列: 创建序列的语法 CREATE SEQUENCE sequence //创建序列名称 [INCREMENT BY n]…

数组转List的3种方法和使用对比!

作者 | 大脑补丁来源 | blog.csdn.net/x541211190/article/details/79597236前言:本文介绍Java中数组转为List三种情况的优劣对比,以及应用场景的对比,以及程序员常犯的类型转换错误原因解析。一.最常见方式(未必最佳)…

java 根据类名示例化类_Java即时类| getEpochSecond()方法与示例

java 根据类名示例化类即时类getEpochSecond()方法 (Instant Class getEpochSecond() method) getEpochSecond() method is available in java.time package. getEpochSecond()方法在java.time包中可用。 getEpochSecond() method is used to get the number of seconds from t…

oracle10g备份导入

2019独角兽企业重金招聘Python工程师标准>>> //导出 exp test/testgdsoft filed:\gd.dmp //删用户 drop user wkwx cascade; //用PLSQL创建数据数据库 create user hzjzjn identified by hzjzjn default tablespace BDP_DATABD; grant CREATE USER,DROP USER,ALTE…

VisualSVNServer的使用

VisualSVNServer的使用1_服务端初识1.1_创建新仓库1.2_创建用户并分配权限1_服务端初识 1.1_创建新仓库 右击Repository,点击create 点击下一步 输入仓库名 右击空白处,点击新建,点击project structure 输入工程名 1.2_创建用户并分…

安利一个IDEA骚操作:一键生成方法的序列图

在平时的学习/工作中,我们会经常面临如下场景:阅读别人的代码阅读框架源码阅读自己很久之前写的代码。千万不要觉得工作就是单纯写代码,实际工作中,你会发现你的大部分时间实际都花在了阅读和理解已有代码上。为了能够更快更清晰地…

overflow滚动条属性

做网页的时候,因为网页内容的长短不一样,并且滚动条的策略默认是自动,所以网页的滚动条根据内容一会有一会没有。我的网页做的是居中的,所以滚动条在有和没有的时候,会影响网页内容的位置,这样感觉不太好&a…

c#中textbox属性_C#.Net中带有示例的TextBox.Multiline属性

c#中textbox属性Here we are demonstrating use of Multiline property of the TextBox Control. 在这里,我们演示了TextBox控件的Multiline属性的使用。 Multiline property contains two values: 多行属性包含两个值: True: We can enter text in mo…

MATLAB新手教程

MATLAB新手教程 1.MATLAB的基本知识 1-1、基本运算与函数 在MATLAB下进行基本数学运算,仅仅需将运算式直接打入提示号(>>)之後,并按入Enter键就可以。比如: >> (5*21.3-0.8)*10/25 an…

嗯,查询滑动窗口最大值的这4种方法不错....

作者 | 王磊来源 | Java中文社群(ID:javacn666)转载请联系授权(微信ID:GG_Stone)本文已收录至 Github《小白学算法》系列:https://github.com/vipstone/algorithm这是一道比较基础的算法题&…

Oracle创建视图、通过视图创建表

创建视图: create or replace view v$_tst23 as select e.ename,d.dname from emp e left join dept d on e.deptno d.deptno;创建表: --如果表已存在,先删除 --drop table tst23a; --创建表格(通过视图) --可以在whe…

SVN客户端使用

SVN客户端使用1. 复制服务端URL2. 在客户端电脑新建文件夹用于存储版本代码3. 右击空白处,checkout4. 进入trunk目录,即可尝试新建文件并上传到服务端4.其他客户端更新版本5.解决代码冲突期间由于之前登陆过并设置为记住密码,所以整个过程并没…

c ++ stl_获取列表的第一个和最后一个元素| C ++ STL

c stlGiven a list with some of the elements, we have to access its first and last elements of the list in C (STL) program. 给定包含某些元素的列表,我们必须在C (STL)程序中访问列表的第一个和最后一个元素。 列表的front()和back()函数 (front() and ba…