
/
取得当前月第一天
@param date
@return
Date: 2012-5-14下午03:53:37
/
public static Date getMonthFirst(Date date) {
try {
SimpleDateFormat sdfShort = new SimpleDateFormat(DATE_FORMAT_SHORT);
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
SimpleDateFormat sdfMonth = new SimpleDateFormat("MM");
return sdfShortparse(sdfYearformat(date) + "-" + sdfMonthformat(date) + "-01");
} catch (ParseException e) {
eprintStackTrace();
}
return null;
}
/
取得当前月最后一天
@param date
@return
Date: 2012-5-14下午03:53:57
/
public static Date getMonthLast(Date date) {
try {
SimpleDateFormat sdfShort = new SimpleDateFormat(DATE_FORMAT_SHORT);
SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
SimpleDateFormat sdfMonth = new SimpleDateFormat("MM");
int year = IntegervalueOf(sdfYearformat(date));
int month = IntegervalueOf(sdfMonthformat(date));
int day = getMonthDays(year, month);
return sdfShortparse(year + "-" + month + "-" + day);
} catch (ParseException e) {
eprintStackTrace();
}
return null;
}
第一种方法:
var timestamp = Dateparse(new Date());
结果:1280977330000
第二种方法:
var timestamp = (new Date())valueOf();
结果:1280977330748
第三种方法:
var timestamp=new Date()getTime();
结果:1280977330748
第一种:获取的时间戳是把毫秒改成000显示,
第二种和第三种是获取了毫秒的时间戳。
以上就是关于如何求当前时间的的第一天和最后一天的时间戳全部的内容,包括:如何求当前时间的的第一天和最后一天的时间戳、js获取指定时间戳、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)