代碼很簡(jiǎn)單,功能也很實(shí)用,這里就不多廢話(huà)了。
- public Date getdate(int i) // //獲取前后日期 i為正數(shù) 向后推遲i天,負(fù)數(shù)時(shí)向前提前i天
- {
- Date dat = null;
- Calendar cd = Calendar.getInstance();
- cd.add(Calendar.DATE, i);
- dat = cd.getTime();
- SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Timestamp date = Timestamp.valueOf(dformat.format(dat));
- return date;
- }
以上代碼就是本文所述的全部?jī)?nèi)容了,希望大家能夠喜歡。
請(qǐng)您花一點(diǎn)時(shí)間將文章分享給您的朋友或者留下評(píng)論。我們將會(huì)由衷感謝您的支持!