当前位置:网站首页>Time tools
Time tools
2022-07-05 11:57:00 【asahi_ xin】
@SuppressLint({
"SimpleDateFormat"})
public class TimeUtils {
public static String COMPLETE_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static String DATE_FORMAT = "yyyy-MM-dd";
public static String TIME_FORMAT = "HH:mm:ss";
/** * Get the current time String type * * @return Time */
public static String getStringDate(String format) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
Date date = new Date(System.currentTimeMillis());
return simpleDateFormat.format(date);
}
/** * Get the current time long type * * @return Time */
public static long getLongDate() {
return System.currentTimeMillis();
}
/** * long Type time is converted to string * * @param time Time to be converted * @return Conversion time */
public static String formatTime(String format, long time) {
SimpleDateFormat df = new SimpleDateFormat(format);
return df.format(new Date(time));
}
/** * Calculate the number of days between two dates * * @param startDate Starting time * @param endDate End time * @return Days */
public static long getDateDistance(String startDate, String endDate) {
Date newStartDate = null;
Date newEndDate = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
try {
newStartDate = simpleDateFormat.parse(startDate);
newEndDate = simpleDateFormat.parse(endDate);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar startInstance = Calendar.getInstance();
startInstance.setTime(newStartDate);
Calendar endInstance = Calendar.getInstance();
endInstance.setTime(newEndDate);
return (endInstance.getTimeInMillis() - startInstance.getTimeInMillis()) / (1000 * 3600 * 24);
}
/** * Calculate the date minus the time difference * * @param day date * @param num Time difference * @return Calculate the date */
public static String getDateDistance(String day, int num) {
Date newDate;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT);
try {
newDate = simpleDateFormat.parse(day);
Date distance = new Date(newDate.getTime() - (long) num * 24 * 60 * 60 * 1000);
return simpleDateFormat.format(distance);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
}
边栏推荐
猜你喜欢

Pytorch softmax regression

pytorch-权重衰退(weight decay)和丢弃法(dropout)

Linux安装部署LAMP(Apache+MySQL+PHP)

11. (map data section) how to download and use OSM data

pytorch-softmax回归

【Win11 多用户同时登录远程桌面配置方法】
The survey shows that traditional data security tools cannot resist blackmail software attacks in 60% of cases

【yolov5.yaml解析】

Yolov5 target detection neural network -- calculation principle of loss function

【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】
随机推荐
你做自动化测试为什么总是失败?
Mmclassification training custom data
Solve readobjectstart: expect {or N, but found n, error found in 1 byte of
Programmers are involved and maintain industry competitiveness
Reading notes of growth hacker
1个插件搞定网页中的广告
Prevent browser backward operation
Halcon 模板匹配实战代码(一)
1.php的laravel创建项目
Multi table operation - Auto Association query
Simply solve the problem that the node in the redis cluster cannot read data (error) moved
11. (map data section) how to download and use OSM data
[crawler] Charles unknown error
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
COMSOL -- establishment of geometric model -- establishment of two-dimensional graphics
C operation XML file
查看多台机器所有进程
Riddle 1
查看rancher中debug端口信息,并做IDEA Remote Jvm Debug
[cloud native | kubernetes] actual battle of ingress case (13)