发布网友 发布时间:2022-04-21 03:37
共3个回答
热心网友 时间:2022-05-19 14:47
JAVA中获取当前系统时间关键代码:
//得到long类型当前时间完整代码:
package com.ob;输出结果:
2017-01-06 12:28:19
热心网友 时间:2022-05-19 16:05
/**
* 获取系统当前时间 <br>
* 方 法 名:getCurrentDate<br>
*
* @param formatStr
* 需要格式的目标字符串例:yyyy-MM-dd
* @return Date 时间对象
*/
publicstatic Date getCurrentDate() {
returnnew Date();
}
publicString getTodayString() {
Calendarca = Calendar.getInstance();
StringcurrDate = ca.get(Calendar.YEAR) + "-"
+(ca.get(Calendar.MONTH) + 1) + "-"
+ca.get(Calendar.DAY_OF_MONTH);
intweek = ca.get(Calendar.DAY_OF_WEEK);
Stringweekday = "";
if(week == 1) {
weekday= "星期天";
}else if (week == 2) {
weekday= "星期一";
}else if (week == 3) {
weekday= "星期二";
}else if (week == 4) {
weekday= "星期三";
}else if (week == 5) {
weekday= "星期四";
}else if (week == 6) {
weekday= "星期五";
}else if (week == 7) {
weekday= "星期六";
}
returncurrDate + " " + weekday;
}
热心网友 时间:2022-05-19 17:39
system.currenttimemillis()