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

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

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

  • getDayOfYear() method is used to get the field value day-of-year from this date-time object.

    getDayOfYear()方法用于从该日期时间对象获取年月日的字段值。

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

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

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

    getDayOfYear()方法在获取一年中的某天时不会引发异常。

Syntax:

句法:

    public int getDayOfYear();

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is int, it returns the value day-of-year field and the number of days in a year starts from 1 to 365 (i.e. for Non-Leap Year) or from 1 to 366 (i.e. for Leap Year).

此方法的返回类型为int ,它返回值“年的年”字段,并且一年中的天数从1到365(即非-年)或1到366(即Le年)开始)。

Example:

例:

// Java program to demonstrate the example
// of getDayOfYear() method of LocalDateTime
import java.time.*;
public class GetDayOfWeekOfLocalDateTime {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
// day-of-week that is an enum DayOfWeek
// from this date-time object (da_ti1)
DayOfWeek dow = da_ti1.getDayOfWeek();
// Display dow
System.out.println("da_ti1.getDayOfWeek(): " + dow);
// Here, this method returns the field value
// day-of-week that is an enum DayOfWeek
// from this date-time object (da_ti2)
dow = da_ti2.getDayOfWeek();
// Display dow
System.out.println("da_ti2.getDayOfWeek(): " + dow);
}
}

Output

输出量

LocalDateTime da_ti1 and da_ti2:
da_ti1: 2005-10-05T10:10:10
da_ti2: 2020-06-05T02:47:28.362477da_ti1.getDayOfWeek(): WEDNESDAY
da_ti2.getDayOfWeek(): FRIDAY

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

Java LocalDateTime类| 带示例的getDayOfYear()方法相关推荐

  1. Java LocalDate类| 带示例的getDayOfYear()方法

    LocalDate类的getDayOfYear()方法 (LocalDate Class getDayOfYear() method) getDayOfYear() method is availab ...

  2. Java LocalDateTime类| 带示例的getDayOfWeek()方法

    LocalDateTime类getDayOfWeek()方法 (LocalDateTime Class getDayOfWeek() method) getDayOfWeek() method is ...

  3. Java LocalDateTime类| 带示例的getMinute()方法

    LocalDateTime类getMinute()方法 (LocalDateTime Class getMinute() method) getMinute() method is available ...

  4. Java LocalDateTime类| 带示例的compareTo()方法

    LocalDateTime类compareTo()方法 (LocalDateTime Class compareTo() method) compareTo() method is available ...

  5. java中get接口示例_Java LocalDateTime类| 带示例的get()方法

    java中get接口示例 LocalDateTime类的get()方法 (LocalDateTime Class get() method) get() method is available in ...

  6. java 根据类名示例化类_Java LocalDateTime类| 带示例的getNano()方法

    java 根据类名示例化类 LocalDateTime类getNano()方法 (LocalDateTime Class getNano() method) getNano() method is a ...

  7. java的equals方法_Java LocalDateTime类| 带示例的equals()方法

    java的equals方法 LocalDateTime类equals()方法 (LocalDateTime Class equals() method) equals() method is avai ...

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

    java getmonth LocalDateTime类getMonth()方法 (LocalDateTime Class getMonth() method) getMonth() method i ...

  9. getlong_Java LocalDateTime类| 带示例的getLong()方法

    getlong LocalDateTime类的getLong()方法 (LocalDateTime Class getLong() method) getLong() method is availa ...

最新文章

  1. R语言计算dataframe数据列中各分类的计数(类似pandas value_counts函数功能)
  2. SSL剥离工具sslstrip
  3. Java绘制基本图形
  4. 计算机系统组装 维护常用工具及其作用,《计算机系统组装维护》课程实用标准.doc...
  5. K8S Learning(3)——资源管理
  6. webpack2 实践系列(二)— entry 和 output
  7. 试用到期_各大化妆品品牌试用装广告
  8. 20200707:动态规划专题之不同路径
  9. java中的greeting_JAVA基础知识——字符串
  10. jQuery用户从服务器端注册登录
  11. android 发送显示广播,如何查看Android系统当前发送了什么广播
  12. java并发编程(7)-- 线程 自旋锁
  13. 一阶惯性环节的性能分析——自动控制原理基础补充(二)
  14. C语言计算星历位置,GPS广播星历计算卫星位置和速度
  15. Google 搜索服务退出中国
  16. echarts 关系图 力引导布局
  17. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true
  18. java 打压缩包_java将文件打成zip包
  19. 房屋租赁合同中“天价违约金”的约定是否有效?
  20. 2020.10.29腾讯QQ音乐社招前端电话一面总结

热门文章

  1. pppoe linux 配置文件,linux PPPOE服务端配置
  2. 电工结业试卷_电工技术基础结业考试试卷
  3. button设置disabled属性不生效_jQuery属性节点
  4. android手机微信收藏功能实现,Android模仿微信收藏文件的标签处理功能
  5. [算法]浅谈求n范围以内的质数(素数)
  6. nginx自定义500、404错误页面
  7. powerdns与nginx结合实现以域名和IP方式访问web服务器80端口时分别跳转到不同页面...
  8. ZooKeeper学习笔记—配置管理
  9. 反转链表-剑指offer-16
  10. raidrive安装失败_记一次RaiDrive映射OneDrive遇到的问题