//按天计时
public static String CountTime1(long time) {
long days = time/ (1000 * 60 * 60 * 24);
long hours = (time% (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (time% (1000 * 60 * 60)) / (1000 * 60);
long seconds = (time% (1000 * 60)) / 1000;
return days + " 天 " + hours + "小时 "+ minutes +" 分钟 "+seconds +"秒";
}
//按小时计时
public static String CountTime2(long time) {
long hours = time/ (1000 * 60 * 60);
long minutes = (time% (1000 * 60 * 60)) / (1000 * 60);
long seconds = (time% (1000 * 60)) / 1000;
return hours + "小时 "+ minutes +" 分钟 "+seconds +"秒";
}
//按分钟计时
public static String CountTime3(long time) {
long minutes = time / (1000 * 60);
long seconds = (time% (1000 * 60)) / 1000;
return minutes +" 分钟 "+seconds +"秒";
}
以及mysql日期语句
上个月的第一天:
select date_sub(date_sub(date_format(now(), ‘%y-%m-%d’),
interval extract(day from now()) - 1 day),
interval 1 month);
上个月的最后一天:
select date_sub(date_sub(date_format(now(), ‘%y-%m-%d’),
interval extract(day from now()) day),
interval 0 month);
这个月的第一天:
select date_sub(date_sub(date_format(now(), ‘%y-%m-%d’),
interval extract(day from now()) - 1 day),
interval 0 month);
这个月的最后一天:
select date_sub(date_sub(date_format(now(), ‘%y-%m-%d’),
interval extract(day from now()) day),
interval - 1 month);