当前位置:网站首页>Calendar time operation
Calendar time operation
2022-06-09 02:37:00 【Gentle ~】
calendar Is a variable Date object , Once modified, the time represented by its object itself will change .
import javax.xml.crypto.Data;
import java.util.Calendar;
import java.util.Date;
/** The goal is : Calendar class Calendar Use , You can get more information . Calendar Represents the calendar object corresponding to the current date of the system . Calendar Is an abstract class , You can't create objects directly . Calendar Syntax for calendar class to create calendar objects : Calendar rightNow = Calendar.getInstance(); Calendar Methods : 1.public static Calendar getInstance(): Return an object of calendar class . 2.public int get(int field): Get the information of a field in the date . 3.public void set(int field,int value): Modify a field information of the calendar . 4.public void add(int field,int amount): Add... To a field / Decrease the specified value 5.public final Date getTime(): Get the current date object . 6.public long getTimeInMillis(): Get the current time in milliseconds Summary : remember . */
public class CalendarDemo{
public static void main(String[] args) {
// 1、 Get the calendar object of the system at the moment
Calendar cal = Calendar.getInstance();
System.out.println(cal);
// 2、 Get calendar information :public int get(int field): Get the information of a field in the date .
int year = cal.get(Calendar.YEAR);
System.out.println(year);
int mm = cal.get(Calendar.MONTH) + 1;
System.out.println(mm);
int days = cal.get(Calendar.DAY_OF_YEAR) ;
System.out.println(days);
// 3、public void set(int field,int value): Modify a field information of the calendar .
// cal.set(Calendar.HOUR , 12);
// System.out.println(cal);
// 4.public void add(int field,int amount): Add... To a field / Decrease the specified value
// Excuse me, 64 What time is the day after
cal.add(Calendar.DAY_OF_YEAR , 64);
cal.add(Calendar.MINUTE , 59);
// 5.public final Date getTime(): Get the current date object .
Date d = cal.getTime();
System.out.println(d);
// 6.public long getTimeInMillis(): Get the current time in milliseconds
long time = cal.getTimeInMillis();
System.out.println(time);
}
}
边栏推荐
- Golang of knowledge sharing -- a function based on whether a folder exists and whether a file exists
- C# 基础篇
- Should flying books be ecological? Analyze the first independent SaaS case of all in flybook
- 蓝桥杯_青蛙的约会_扩展欧几里得
- Go技術日報(2022-06-07)——go程序員開發效率神器匯總
- Acwing 791 high precision addition
- 杰理之SPI 从机【篇】
- FRP construction
- Rcgi column - region of Overseas Social Market Research (including lottery)
- 4426 divisible substring (enumeration + number theory)
猜你喜欢

One month soft test | experience sharing of intermediate test for software designers (with learning materials)

20. Class E power amplifier design for ads usage record (Part 1)
![[coding streaming] installation and use of SRS streaming media server](/img/8a/e3462db8425377d32ec2ef22c1ccf3.png)
[coding streaming] installation and use of SRS streaming media server

S series · several postures for deleting folders

From the ECS SSRF vulnerability to taking over your alicloud console

Basic principle of digital circuit adder (I)

Blue Bridge Cup_ N-ary linear equations_ Gauss elimination

Embracing out of hospital prescription drugs, Internet medicine should also "get rid of virtual reality"?

21. Class E power amplifier design of ads usage record (medium)

toggleRowSelection()失效的2个重要影响因素
随机推荐
Jedis工具类、适配单个redis以及redis集群
Problems and solutions in using renrenfast
Dynamic programming / memo method n's K splitting n's maximum addend K splitting
Unity中,继承MonoBehaviour游戏对象的生命周期
杰理之如何修改 ad_key 连接的引脚?【篇】
SQLite3 syntax (2)
21、ADS使用记录之E类功放设计(中)
[network protocol] | [01] network byte order big end and small end
20、ADS使用记录之E类功放设计(上)
数据库表无法添加内容显示修改无法保存提示1452错误
Modbus RTU communication routine between Delta Eh3 series PLC and thermostat
Two important influencing factors of togglerowselection() failure
Export related knowledge
蓝桥杯_青蛙的约会_扩展欧几里得
How to modify ad_ Key connected pin? [chapter]
Go Technology Daily (June 7, 2022) - go programmer development efficiency artifact summary
Blue Bridge Cup_ Diophantine equation
动态规划/斐波那契数列
FRP construction
杰理之关于 SPI 主机配置参数的几个说明篇】