日历类的get()方法 (Calendar Class get() method)

  • get() method is available in java.util package.

    get()方法在java.util包中可用。

  • get() method is used to retrieve the value of the given parameter fi(field) of this Calendar.

    get()方法用于检索此Calendar的给定参数fi(field)的值。

  • get() method is a non-static method, it is accessible with the class object and if we try to access the method with the class name then we will get an error.

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

  • get() method may throw an exception at the time of returning the value of the given parameter.

    在返回给定参数的值时, get()方法可能会引发异常。

    ArrayIndexOutOfBoundsException: This exception may throw when the given field is not in a range.

    ArrayIndexOutOfBoundsException:如果给定字段不在范围内,则可能引发此异常。

Syntax:

句法:

    public int get(int fi);

Parameter(s):

参数:

  • int fi – it represents the given Calendar field.

    int fi –代表给定的Calendar字段。

Return value:

返回值:

The return type of the method is int, it returns the given Calendar field value.

方法的返回类型为int ,它返回给定的Calendar字段值。

Example:

例:

// Java Program to demonstrate the example of
// int get() method of Calendar
import java.util.*;
public class GetOfCalendar {public static void main(String[] args) {// Instantiating a Calendar object
Calendar ca = Calendar.getInstance();
// Display current calendar
System.out.println("ca: " + ca.getTime());
// By using get() method is to return
// the value of the given calendar field
int year = ca.get(Calendar.YEAR);
int month = ca.get(Calendar.MONTH);
int day = ca.get(Calendar.DATE);
// Display Calendar Fields
System.out.println("ca.get(Calendar.YEAR): " + year);
System.out.println("ca.get(Calendar.MONTH): " + month);
System.out.println("ca.get(Calendar.DATE): " + day);
}
}

Output

输出量

ca: Fri Jan 24 12:47:42 GMT 2020
ca.get(Calendar.YEAR): 2020
ca.get(Calendar.MONTH): 0
ca.get(Calendar.DATE): 24

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

Java Calendar get()方法与示例相关推荐

  1. cdate在java中_Java Calendar.add方法代码示例

    本文整理汇总了Java中java.util.Calendar.add方法的典型用法代码示例.如果您正苦于以下问题:Java Calendar.add方法的具体用法?Java Calendar.add怎 ...

  2. Java IOUtils.copy方法代码示例(亲测)

    本文整理汇总了Java中org.apache.commons.io.IOUtils.copy方法的典型用法代码示例.如果您正苦于以下问题:Java IOUtils.copy方法的具体用法?Java I ...

  3. java的calendar的get_Java Calendar get()方法与示例

    日历类get()方法get()方法在java.util包中可用. get()方法用于检索此Calendar的给定参数fi(field)的值. get()方法是一个非静态方法,可通过类对象访问,如果尝试 ...

  4. python中weekday_Python calendar.weekday方法代码示例

    本文整理汇总了Python中calendar.weekday方法的典型用法代码示例.如果您正苦于以下问题:Python calendar.weekday方法的具体用法?Python calendar. ...

  5. java calendar.add方法_Java Calendar add()方法与示例

    日历类add()方法add()方法在java.util包中可用. add()方法用于对指定的cal_fi(日历字段)执行相加或相减的时间量. add()方法是一个非静态方法,可通过类对象访问,如果尝试 ...

  6. java user directory,Java ProcessBuilder directory()方法与示例

    语法:public File directory (); public ProcessBuilder directory (File dir); ProcessBuilder类directory()方 ...

  7. Java序列化魔术方法及其示例使用

    在上一篇文章中, 您需要了解有关Java序列化的所有知识 ,我们讨论了如何通过实现Java序列化来启用类的可序列化性. Serializable接口. 如果我们的类未实现Serializable接口, ...

  8. catalog java,Java Connection getCatalog()方法与示例

    通常,目录是一个目录,其中包含有关数据集,文件或数据库的信息.而数据库目录中包含所有数据库,基本表,视图(虚拟表),同义词,值范围,索引,用户和用户组的列表. Connection接口的getCata ...

  9. filepermission java,Java FilePermission getActions()方法与示例

    FilePermission类getActions()方法getActions()方法在java.io包中可用. getActions()方法用于检查此FilePermission和给定对象在路径名和 ...

  10. java方法参数Bundle,Java ResourceBundle keySet()方法及示例

    ResourceBundle类keySet()方法keySet()方法在java.util包中可用. keySet()方法用于从此ResourceBundle及其超级捆绑包中获取所有现有键,以在Set ...

最新文章

  1. 科研SCI论文图片常见问题和错误汇总
  2. MATLAB机器学习系列-5 RBF、GRNN和PNN神经网络原理及其例子代码
  3. box-sizing -- 盒模型
  4. LeetCode 339. 嵌套列表权重和(DFS)
  5. mysql使用技巧_MySQL使用不得不看的几个小技巧
  6. linux 先编译 再安装,Linux下编译安装FFmpeg
  7. android数据截取字符串数组,android - 从Android Studio中的字符串数组获取特定字符串 - SO中文参考 - www.soinside.com...
  8. word 格式的试题 转 问卷星excel格式
  9. 405 not allowed 问题排查
  10. 图神经网络(CNN)三
  11. 期货模拟盘有效果吗?
  12. python中变量名_python中变量的命名及详解
  13. ffmpeg如何实现MP3转码g711a,
  14. win2003能装mysql_win2003 安装2个mysql实例做主从同步服务配置
  15. 英语语法汇总(3.代词)
  16. 如何下载搜狗翻译读音
  17. 冷笑话,收集很多的冷笑话
  18. BUU-Crypto-异性相吸
  19. 数据结构通讯录查询系统
  20. SQL注入堆叠注入二次注入

热门文章

  1. 【Linux】循序渐进学运维-服务篇-实验环境准备
  2. sql 截取json数据_PostgreSQL 12 新特性解读之一|支持 SQL/JSON path
  3. ecology8流程表单常用js
  4. 认识非编系统软件EDIUS Pro 9
  5. Dubbo服务Spi机制和原理
  6. 阿里NASA的深意:巨头正名还是其他?
  7. 支付宝 Firefox 安全控件使用 FAQ
  8. 智能手机背后的利益链:赚了满钵的供应商,提心吊胆的新技术者
  9. 【学习笔记】3篇关于表情识别的文章
  10. 最新站长必备在线工具箱系统源码/含上百款工具/带后台版本/自适应模板/优化修复版