当前位置:网站首页>Small knowledge of common classes
Small knowledge of common classes
2022-07-25 10:16:00 【Look at the bugs】
StringBuffer
StringBuffer sb=new StringBuffer();
//1,append Additional
sb.append("kankan");
//2,insert() Add or insert
sb.insert(0,12);
//3,replace() Replace
sb.replace(0,2,"world");
//4,delete Delete
sb.delete(0,2);
System.out.println(sb.toString());
Calendar The use of the class
Calendar calendar=Calendar.getInstance();
System.out.println(calendar.getTime().toLocaleString());// Get the current time
System.out.println(calendar.getTimeInMillis());// from 1970 The number of milliseconds from January 1 to now
// Get date
int year=calendar.get(calendar.YEAR);
int month=calendar.get(calendar.MONTH); // from 0-11 Start
int day=calendar.get(calendar.DAY_OF_MONTH);
int hour=calendar.get(calendar.HOUR_OF_DAY);
int minute=calendar.get(calendar.MINUTE);
int second=calendar.get(calendar.SECOND);
System.out.println(year+" year "+month+" month "+day+" Japan "+hour+" when "+minute+" branch "+second);
// Modification time
Calendar calendar2=Calendar.getInstance();
calendar2.set(calendar.DAY_OF_MONTH,19) ;// Set days to 19
System.out.println(calendar2.getTime().toLocaleString());
//add Method modification time
calendar2.add(calendar.HOUR,1); // Add one to the hours , Subtraction can input negative numbers directly
System.out.println(calendar2.getTime().toLocaleString());
simpleDateFormate class
// use SimpleDateFormat Class will Date Convert to string
SimpleDateFormat sdf=new SimpleDateFormat("yyy year MM month dd Japan HH:mm:ss");
//2, Create a Date
Date date=new Date();
// Convert date to string
String str =sdf.format(date);
System.out.println(str);
边栏推荐
猜你喜欢
随机推荐
CentOs安装redis
UE4 快速找到打包失败的原因
Duplicate SSL_ Anti spoofing, spoofing attacks and deep forgery detection using wav2vec 2.0 and data enhanced automatic speaker authentication
Dataset 和 Dataloader数据加载
IDEA整体字体大小修改
Dynamic planning, shopping list problem
cookie and session
记录一些JS工具函数
MVC three-tier architecture understanding
Summary of most consistency problems
Use and principle of rest
C3D模型pytorch源码逐句详析(三)
字典树的使用
Swing组件
JS uses requestanimationframe to detect the FPS frame rate of the current animation in real time
数据库MySQL详解
Exception handling exception
canal实现mysql数据同步
简易加法计算器
用户喜好









