java日历类add方法_Java日历computeTime()方法及示例
java日历类add方法
日历类computeTime()方法 (Calendar Class computeTime() method)
computeTime() method is available in java.util package.
java.util包中提供了computeTime()方法 。
computeTime() method is for conversion of current field values to the ms(millisecond) time value time in fields().
computeTime()方法用于将当前字段值转换为fields()中的ms(毫秒)时间值time。
computeTime() method is a non-static method, it is accessible with the class object and if we try to access these methods with the class name then we will get an error.
computeTime()方法是一种非静态方法,可通过类对象访问,如果尝试使用类名称访问这些方法,则会收到错误消息。
computeTime() method does not throw an exception at the time of updating current field values.
在更新当前字段值时, computeTime()方法不会引发异常。
Syntax:
句法:
protected abstract void computeTime();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of the method is void, it returns nothing.
该方法的返回类型为void ,不返回任何内容。
Example:
例:
// Java Program to demonstrate the example of
// void computeTime() method of Calendar
import java.util.*;
public class ComputeTimeOfCalendar extends GregorianCalendar {public static void main(String[] args) {// Instantiating a Calendar object
ComputeTimeOfCalendar ca = new ComputeTimeOfCalendar();
// Display current calendar
System.out.println("ca: " + ca.getTime());
// By using clear(int fi) method to set the
// field unset
ca.clear(GregorianCalendar.MONTH);
// Display calendar
System.out.println("ca.clear(GregorianCalendar.MONTH): " + ca.getTime());
// By using set() method is to set a month
// and invoke computeTime()
ca.set(GregorianCalendar.MONTH, 6);
ca.computeTime();
// Display calendar
System.out.println("ca.set(GregorianCalendar.MONTH,6): " + ca.getTime());
}
}
Output
输出量
ca: Fri Jan 24 12:32:39 GMT 2020
ca.clear(GregorianCalendar.MONTH): Fri Jan 24 12:32:39 GMT 2020
ca.set(GregorianCalendar.MONTH,6): Fri Jul 24 12:32:39 GMT 2020
翻译自: https://www.includehelp.com/java/calendar-computetime-method-with-example.aspx
java日历类add方法
java日历类add方法_Java日历computeTime()方法及示例相关推荐
- java日历类add方法_Java日历computeFields()方法及示例
java日历类add方法 日历类的computeFields()方法 (Calendar Class computeFields() method) computeFields() method is ...
- java日历类add方法_Java日历setFirstDayOfWeek()方法与示例
java日历类add方法 日历类setFirstDayOfWeek()方法 (Calendar Class setFirstDayOfWeek() method) setFirstDayOfWeek( ...
- java日历类add方法_Java日历setMinimalDaysInFirstWeek()方法与示例
java日历类add方法 日历类setMinimalDaysInFirstWeek()方法 (Calendar Class setMinimalDaysInFirstWeek() method) se ...
- java中日历类的用法_java日期类的用法
java日期类的用法 不管你是处理财务交易还是计划着下一步的行动,你都要知道怎样在Java中建立,使用和显示日期.这需要你简单的查阅一下相应类的API参考:一个日期可以创建3个相关类的对象.这篇文章告 ...
- java 获取类的注解_Java 自定义注解通过反射获取类、方法、属性上的注解
反射 JAVA中的反射是运行中的程序检查自己和软件运行环境的能力,它可以根据它发现的进行改变.通俗的讲就是反射可以在运行时根据指定的类名获得类的信息. 注解的定义 注解通过 @interface 关键 ...
- java的lookup方法_Java ObjectStreamClass lookup()方法与示例
ObjectStreamClass类lookup()方法lookup()方法在java.io包中可用. lookup()方法用于查找可以序列化的类的描述符. lookup()方法是静态方法,可以使用类 ...
- java实体类实现抽象类_java接口、抽象类、实体类关系介绍
接口:接口是一个引用类型,与类相似,不过在接口中只能包含常量,方法名和嵌套类型.没有构造器,所以不能被实例化只能被类所实现或者被另外的接口所继承.在接口中声明的方法没有方法体. 抽象类:将类层次中共有 ...
- java方法重载和重载方法_Java中的方法重载
java方法重载和重载方法 The concept of Method Overloading in Java is where a class can have multiple methods w ...
- Java 编程问题:七、Java 反射类、接口、构造器、方法和字段
原文:Java Coding Problems 协议:CC BY-NC-SA 4.0 贡献者:飞龙 本文来自[ApacheCN Java 译文集],自豪地采用谷歌翻译. 本章包括涉及 Java 反射 ...
最新文章
- Python os.getcwd() 方法
- 来个邪恶假说,假如有人把支付宝所有存储服务器炸了,我们在里边的钱是不是都丢了?
- 有感:仅在面试时攻克 MySQL 还不够
- 计算机系统 过程调用
- TreeView递归系统目录
- 2022中国物联网行业研究报告
- python整理-day4
- jvm学习笔记(2)——java对象的内存布局
- vSAN其实很简单-兼容列表那些事
- sql示例_SQL Server Lead功能概述和示例
- 如何清洗 Git Repo 代码仓库
- Android View之用户界面...
- android adb模拟点击,Android adb 模拟滑动 按键 点击事件(示例代码)
- 计算机导论学习综合训练及其答案
- 机器学习-神经网络NN
- Android vivo美颜相机相册 照亮你的美 图片压缩 图片滤镜,裁剪(附带完整项目源码)
- 整理的一些java基础知识点,欢迎补充指正
- 实现信息化企业供应链管理,上云是大势所趋
- 女大学生最爱不释手的网址
- 10分钟手把手教你用Android手撸一个简易的个人记账App
热门文章
- Linux启动更新命令,Linux更新和查询命令chkconfig详细介绍
- python列表字典_Python常用对字典、列表的操作
- linux远程拷贝免手动输入密码,scp远程拷贝避免输入密码
- winpe制作u盘启动盘_怎么制作u盘启动盘 u盘启动盘制作方法【介绍】
- arima模型_[不说人话系列]-ARIMA模型
- python函数的作用域_python学习第五篇 函数 变量作用域
- 北京科技大学计算机硕士,北京科技大学计算机专业硕士只有面授上课吗
- apt-get包管理详解
- MIP技术交流分享(3月9日)
- CPR认证-建材CE认证-305/2011/EU