/**
* 得到几天前的时间
* @param d
* @param day
* @return
*/
public static Date getDateBefore(Date d,int day){
Calendar now =Calendar.getInstance();
now.setTime(d);
now.set(Calendar.DATE,now.get(Calendar.DATE)-day);
return now.getTime();
}
/**
* 得到几天后的时间
* @param d
* @param day
* @return
*/
public static Date getDateAfter(Date d,int day){
Calendar now =Calendar.getInstance();
now.setTime(d);
now.set(Calendar.DATE,now.get(Calendar.DATE)+day);
return now.getTime();
}
/**
*获取今天的时间的凌晨 到 23点
*
*/
private void initTime(){
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
this.startTime=sdf.format(cal.getTime())+" 00:00:00";
this.endTime=sdf.format(cal.getTime())+" 23:59:59";
}
//判断是不是昨天.同一天,前天
//判断是不是今天
private boolean isToday(Date time){
try {
Date nowTime=new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String todayStr = format.format(nowTime);
Date today = format.parse(todayStr);
long starttime=today.getTime();
long endtime=today.getTime()+86400000;
if(starttime<=time.getTime() && time.getTime()<=endtime){
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
相关推荐
Android写了一个日历小控件,请大家多多指教 这个日历控件是改一个可以滑动的scrollview嵌套一个GridView按月份展示。期间查了很多资料,呕心沥血之作。。。由于刚刚开始研究Android,希望多多给意见。
Active Desktop Calendar是一个可完全定制的日期定制软件,提供日期记录,任务,闹钟以及联系方法等功能,并可与桌面背景进行无缝融合以及提供足够互动性。使用者可将层中的数据进行有效组织,并在本地网络內进行...
本文介绍了WdatePicker.js时间插件使用,分享给大家,具体如下: 引用: 在项目中引用“plugin-clander”文件夹。 在html中引用”WdatePicker.js”即可。 [removed][removed] 1.没有对控件进行设置 <input ...
仿365日历,左右滑动切换月份,选择一天,上下滑动收缩
如果无法连接社区,可以使用离线插件,在./obsidian文件加中新建plugins文件夹,然后将插件大全中对应你想要的插件解压到plugins文件夹中,重启obsidian,然后在第三方插件中关闭安全模式后就可以看到了。
AWS-AutoScaling-Google-Calander 允许您通过更改 Google Clander 中的事件来控制 AWS AutoScaling 组中所需服务器数量的脚本第一: npm install 第二:使用config/default.yaml作为基础在config/local.yaml配置您的...
简单日历 非常小
GridView实现的日历,包含农历算法,