QQ网名大全

用j**a如何实现 1小时前 1分钟前

public static void main(string[] args) {
simpledateformat sdf=new simpledateformat("yyyy-mm-dd hh:mm:ss");
calendar c=calendar.getinstance();
system.out.println(sdf.format(c.gettime()));
c.add(calendar.hour_of_day, -1);//1小时前
system.out.println(sdf.format(c.gettime()));
c=calendar.getinstance();
c.add(calendar.minute, -1);//1分钟前
system.out.println(sdf.format(c.gettime()));
}
佚名
2024-12-23 08:19:11
最佳回答
类似问题(10)