如何在jstl的时间戳中添加30天 [英] How to add 30 days in a timestamp in jstl

查看:455
本文介绍了如何在jstl的时间戳中添加30天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在时间戳中将30天添加到当前系统日期.我该如何实现?我有以下代码:

I need to add 30 days to the current system date in timestamp. How can I acheive that? I am having below code:

<%

    Date date= new Date();
    long time = date.getTime();
    Timestamp ts = new Timestamp(time);
     %> 
    <c:set var="currentDate"><%=ts%></c:set>
    <c:if test="${startDate lt currentDate}">
        <c:if test="${endDate gt currentDate}">

我怎样才能使ts + 30?预先感谢.

How can I make ts+ 30? Thanks in advance.

推荐答案

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%
 Date date= new Date();
 Calendar cal = Calendar.getInstance();
 cal.setTime (date);
 cal.add (Calendar.DATE, 30);
 date = cal.getTime ();
%>
<c:set var="currentDate"><%=date%></c:set>
<c:out value="currentDate"/>

这篇关于如何在jstl的时间戳中添加30天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆