首页 返回3个月前的时间

返回3个月前的时间

举报
开通vip

返回3个月前的时间返回3个月前的时间 import java.util.Calendar; import java.util.Date; import java.text.SimpleDateFormat; /** getMonthBefore方法完成根据时间类型的不同得到当前时间前的三个月时间前的时间*/ private static String getMonthBefore(int timeType) { SimpleDateFormat dat = new SimpleDateFormat("yyyy-MM-01...

返回3个月前的时间
返回3个月前的时间 import java.util.Calendar; import java.util.Date; import java.text.SimpleDateFormat; /** getMonthBefore 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 完成根据时间类型的不同得到当前时间前的三个月时间前的时间*/ private static String getMonthBefore(int timeType) { SimpleDateFormat dat = new SimpleDateFormat("yyyy-MM-01");// 格式化对象 SimpleDateFormat month = new SimpleDateFormat("yyyy-MM"); Calendar calendar = Calendar.getInstance();// 日历对象 calendar.add(Calendar.MONTH, -3);// 为负月份减,为正月份加 if (timeType == FULL_FORMAT) return dat.format(calendar.getTime()); else return month.format(calendar.getTime()); } js的方法: function getMonthBefore(timeType){ // TODO 如果用户不输入时间,则把起始时间设置为三个月前的时间 var date = new Date(); var retureValue = ""; if (timeType==1){ date.setMonth(date.getMonth()-3); retureValue =date.format('yyyy-MM'); } if(timeType==0){ date.setMonth(date.getMonth()-3); retureValue =date.format('yyyy-MM-01'); } // alert(retureValue); return retureValue; } Date.prototype.format = function(format) { var o = { "M+" : this.getMonth()+1, // month "d+" : this.getDate(), // day "h+" : this.getHours(), // hour "m+" : this.getMinutes(), // minute "s+" : this.getSeconds(), // second "q+" : Math.floor((this.getMonth()+3)/3), // quarter "S" : this.getMilliseconds() // millisecond } if(/(y+)/.test(format)) format=format.replace(RegExp.$1,(this.getFullYear()+"").sub str(4 - RegExp.$1.length)); for(var k in o) if(new RegExp("("+ k +")").test(format)) format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); return format; }
本文档为【返回3个月前的时间】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_594905
暂无简介~
格式:doc
大小:14KB
软件:Word
页数:0
分类:
上传时间:2017-10-10
浏览量:17