怎么获得当前日期 Date d = new Date();SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");System.out.println(tempDate.format(d)); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Date d = new Date();SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");System.out.println(tempDate.format(d)); 在写这个之前要先导包进去。如: java.util.* jsp里用前面的代码加 <%=tempDate.format(d)=>100分啊,好多 包好象引错了,java.text.SimpleDateFormat,误倒人家 <SCRIPT>function Refresh()...{ Time.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay()); setTimeout("Refresh()",1000);}var timer=setTimeout("Refresh()",1000);</SCRIPT><DIV style="background-color:#eeeeee" id="Time"></DIV>不过貌似structs有calendar标签可以直接拿的呀 不要用JS获取日期对象赋值,JS是获取的客户端的值struts里应该没有标签能够直接做到,在action里取到系统日期java.util.Date类型,在jsp上可以通过s:date标签来对其格式化。如:<s:date name="person.birthday" format="dd/MM/yyyy" /> qq技术群java jsp qun 27324553 (1群) 34894728 (2群) 18175454 (3群高级群) 60440677 (4群)装死误入 // 取得系统時間Calendar rightNow = Calendar.getInstance();SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");String sysdate = format.format(rightNow.getTime()); <%java.util.Date now = new java.util.Date()pageContext.setAttribute("now",now);%><s:date name="#attr.now" format="dd/MM/yyyy" nice="true"/>你可以在资源文件中配置struts.date.format=yyy年MM月dd日当然,你也可以在Action中声明一个String now;//get&set<s:date name="now" format="dd/MM/yyyy" nice="true"/> // =============取系统时间start================ Calendar cal = Calendar.getInstance(); // -200代表200天前这个时候的时间 cal.add(Calendar.DAY_OF_YEAR, -200); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); String nowtime = sdf.format(cal.getTime()); // =============取系统时间end================ 引用 1 楼 harryzyp 的回复:Date d = new Date(); SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(tempDate.format(d)); 这个不错! 不能用 JavaScript 赋值,JavaScript 只能获得客户端的时间。 <script language="javascript"> function getTodayDate(){ var todaydate = new Date(); var curyear = todaydate.getYear(); var curmonth = todaydate.getMonth()+1; var curday = todaydate.getDate(); //这里通过id进行显示 document.getElementById("inputendyear").value = curyear; document.getElementById("inputendmonth").value = curmonth; document.getElementById("inputendday").value = curday; }</script> 应该是这样,上面的是我直接从代码里复制出来的,不合适 document.getElementById("displaydate").innerHTML = curyear+"年"+curmonth +"月"+curday+"日"; Date d = new Date(); SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd"); System.out.println(tempDate.format(d)); 晕前面已经很详细了就new一个date,再format一下 Date dt=new Date(); SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");需要注意的是formatstring:"yyyy-MM-dd",大小寫注意! Date dt=new Date(); SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");需要注意的是formatstring:"yyyy-MM-dd",大小寫注意! Date dt=new Date(); SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");需要注意的是formatstring:"yyyy-MM-dd",大小寫注意! 在action里取到系统日期java.util.Date类型 自己写一个标签tag,调用一个static函数 关于项目路径问题 批量删除功能 dtree问题!!各位大哥大姐帮帮忙啊! 如何在表单提交,保存数据库后,根据保存结果弹出模态对话框? 为什么我的servlet运行就是有问题 jsp向servlet传值出错 求救----- 请问两种过期方式的区别(采用META方式和response.setHeader方式)? 如何实现以下功能? 支付宝支付问题 在后台出来这些东西,不知道是什么警告 The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(tempDate.format(d));
100分啊,好多
function Refresh()...{
Time.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());
setTimeout("Refresh()",1000);
}
var timer=setTimeout("Refresh()",1000);
</SCRIPT>
<DIV style="background-color:#eeeeee" id="Time"></DIV>
不过貌似structs有calendar标签可以直接拿的呀
struts里应该没有标签能够直接做到,在action里取到系统日期java.util.Date类型,在jsp上可以通过s:date标签来对其格式化。如:
<s:date name="person.birthday" format="dd/MM/yyyy" />
27324553 (1群)
34894728 (2群)
18175454 (3群高级群)
60440677 (4群)
装死误入
// 取得系统時間
Calendar rightNow = Calendar.getInstance();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String sysdate = format.format(rightNow.getTime());
java.util.Date now = new java.util.Date()
pageContext.setAttribute("now",now);
%><s:date name="#attr.now" format="dd/MM/yyyy" nice="true"/>你可以在资源文件中配置
struts.date.format=yyy年MM月dd日当然,你也可以在Action中声明一个
String now;//get&set
<s:date name="now" format="dd/MM/yyyy" nice="true"/>
Calendar cal = Calendar.getInstance();
// -200代表200天前这个时候的时间
cal.add(Calendar.DAY_OF_YEAR, -200);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String nowtime = sdf.format(cal.getTime());
// =============取系统时间end================
Date d = new Date();
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(tempDate.format(d));
这个不错!
function getTodayDate(){
var todaydate = new Date();
var curyear = todaydate.getYear();
var curmonth = todaydate.getMonth()+1;
var curday = todaydate.getDate(); //这里通过id进行显示
document.getElementById("inputendyear").value = curyear;
document.getElementById("inputendmonth").value = curmonth;
document.getElementById("inputendday").value = curday;
}</script>
document.getElementById("displaydate").innerHTML = curyear+"年"+curmonth +"月"+curday+"日";
SimpleDateFormat tempDate = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(tempDate.format(d));
就new一个date,再format一下
Date dt=new Date();
SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!
Date dt=new Date();
SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!
Date dt=new Date();
SimpleDateFormat dataformat=new SimpleDateFormat("yyyy-MM-dd");
需要注意的是formatstring:"yyyy-MM-dd",大小寫注意!