当前位置:网站首页>Common member methods of the calendar class
Common member methods of the calendar class
2022-06-24 20:57:00 【Platonic】
| void add(int field, int amount) | For the given calendar field field Add or subtract the specified amount of time amount |
| int get(int field) | int get(int field) |
| static Calendar getInstance() | static Calendar getInstance() |
| Date getTime() | Return a representation of this Calendar Time is worth Date object |
Example :
public class Demo02Calendar {
public static void main(String[] args) {
//demo02();
// demo01();
//demo03();
demo04();
}
/*public int get(int field): Returns the value of the given calendar field
* Parameters : Pass the specified calendar field (YEar,MONTH..)
* Return value : Calendar fields represent specific values
* */
private static void demo01(){
// Use getInstance Method to get Calendar() object
Calendar c=Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int date= c.get(Calendar.DATE);
System.out.println(year+" year ");
System.out.println(month+" month ");
System.out.println(date+" Japan ");
}
//public void set(int field,int value): Set the given calendar field to the given value
private static void demo02(){
// Use getInstance Method to get Calendar() object
Calendar c=Calendar.getInstance();
c.set(Calendar.YEAR,2021);
c.set(Calendar.MONTH,2);
c.set(Calendar.DATE,21);
// You can also set the year, month and day at the same time
// c.set(2021,2,21);
System.out.println();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date= c.get(Calendar.DATE);
System.out.println(year+" year ");
System.out.println(month+" month ");
System.out.println(date+" Japan ");
}
//public abstract void add(int field,int value): Add and subtract specific values ;
private static void demo03(){
// Use getInstance Method to get Calendar() object
Calendar c=Calendar.getInstance();
c.add(Calendar.YEAR,2);
c.add(Calendar.MONTH,2);
c.add(Calendar.DATE,1);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int date= c.get(Calendar.DATE);
System.out.println(year+" year ");
System.out.println(month+" month ");
System.out.println(date+" Japan ");
}
public static void demo04(){
// Use getInstance Method to get Calendar() object
Calendar c=Calendar.getInstance();
Date time = c.getTime();
System.out.println(time);
System.out.println(time.toLocaleString());
}
}边栏推荐
- When querying the database with Gorm, reflect: reflect flag. mustBeAssignable using unaddressable value
- Procedural life: a few things you should know when entering the workplace
- Openvino2022 dev tools installation and use
- Leetcode(455)——分发饼干
- CVPR 2022 remembers Sun Jian! Tongji and Ali won the best student thesis award, and hekaiming was shortlisted
- 首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千
- CVPR 2022缅怀孙剑!同济、阿里获最佳学生论文奖,何恺明入围
- 畅直播|针对直播痛点的关键技术解析
- Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable
- [cann document express issue 05] let you know what operators are
猜你喜欢

Agency mode -- Jiangnan leather shoes factory

图的基本概念以及相关定义

Postman assertion

Background of master data construction

Basic properties and ergodicity of binary tree

Apple doesn't need money, but it has no confidence in its content

Prototype mode -- clone monster Army

Berkeley, MIT, Cambridge, deepmind and other industry leaders' online lectures: towards safe, reliable and controllable AI

Cooking business experience of young people: bloggers are busy selling classes and bringing goods, and the organization earns millions a month

使用gorm查询数据库时reflect: reflect.flag.mustBeAssignable using unaddressable value
随机推荐
IDEA Dashboard
史上最全DPU厂商大盘点(上)
两位湖南老乡,联手干出一个百亿IPO
Learn together and make progress together. Welcome to exchange
Wait for the victory of the party! After mining ebb tide, graphics card prices plummeted across the board
Freshman girls' nonsense programming is popular! Those who understand programming are tied with Q after reading
[performance tuning basics] performance tuning standards
What are the problems with traditional IO? Why is zero copy introduced?
What will you do if you have been ignored by your leaders at work?
maptalks:数据归一化处理与分层设色图层加载
微信小程序中使用vant组件
[普通物理] 光栅衍射
Camera rental management system based on qt+mysql
物联网?快来看 Arduino 上云啦
天天鉴宝暴雷背后:拖欠数千万、APP停摆,创始人预谋跑路?
Jd.com: how does redis implement inventory deduction? How to prevent oversold?
红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
Docker deploy mysql5.7
C语言实现扫雷(简易版)
首个大众可用PyTorch版AlphaFold2复现,哥大开源OpenFold,star量破千