在java中 怎么把获取的系统时间转化成数字
2个回答
展开全部
long time=new Date().getTime();
System.out.println(""+time);
Date date=new Date(time);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(date));
System.out.println(""+time);
Date date=new Date(time);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println(sdf.format(date));
更多追问追答
追问
下面的无法在eclipse里编译
上面的 得到了 很长的一个数字
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Test19 {
public static void main(String[] args) {
// assert args.length==1;
int year, month, date, hour, minute, second;
Calendar now = Calendar.getInstance();
now = Calendar.getInstance();
year = now.get(Calendar.YEAR);
month = now.get(Calendar.MONTH);
date = now.get(Calendar.DATE);
hour = now.get(Calendar.HOUR_OF_DAY);
minute = now.get(Calendar.MINUTE);
second = now.get(Calendar.SECOND);
}
}
public static void main(String[] args) {
// assert args.length==1;
int year, month, date, hour, minute, second;
Calendar now = Calendar.getInstance();
now = Calendar.getInstance();
year = now.get(Calendar.YEAR);
month = now.get(Calendar.MONTH);
date = now.get(Calendar.DATE);
hour = now.get(Calendar.HOUR_OF_DAY);
minute = now.get(Calendar.MINUTE);
second = now.get(Calendar.SECOND);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询