- System.out.println(new java.util.Date());
输出:Thu Jan 27 14:43:28 CST 2011
- System.out.println(new java.util.Date().toLocaleString());
输出:2011-1-27 14:45:21
不过现在toLocaleString()方法已过时,由DateFormat.format(Date date)取代。
- DateFormat ddf = DateFormat.getDateInstance();
- DateFormat dtf = DateFormat.getTimeInstance();
- DateFormat ddtf = DateFormat.getDateTimeInstance();
- Date date = new Date();
- System.out.println("日期:" + ddf.format(date));
- System.out.println("时间:" + dtf.format(date));
- System.out.println("日期时间:" + ddtf.format(date));
- SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance();
- System.out.println("日期时间:" + sdf.format(date));
输出:
日期:2011-2-9
时间:11:16:02
日期时间:2011-2-9 11:16:02
日期时间:2011-2-9 11:16:02
*************以上是在window系统下,linux系统下不能这么处理***********
linux系统下用以上获取回来的初始时间格式与此不同。
分享到:
相关推荐
偶然之间用到这两个方法 然后在数字转换成字符串的时候,并没有感觉这两个方法有什么区别,如下: var e=123 e.toString() "123" e.toLocaleString() ...var sd=new Date() sd Wed Feb 15 2017 11:2
目录 1、时间格式化常规思路2、时间格式化toLocaleString() 1、时间格式化常规思路 2、时间格式化toLocaleString() 研究Object对象的时候,看到了 toLocaleString() 这个方法可以很简单的实现时间格式化。...
The Date Object Section 3.10. Regular Expressions Section 3.11. Error Objects Section 3.12. Primitive Data Type Wrapper Objects Chapter 4. Variables Section 4.1. Variable Typing Section...
date.toLocaleString());//转化为本地时间 alert(date.getFullYear());//显示年份 alert(date.getMonth() + 1);//显示月份 0-11,需要加1 alert(date.getDate());//显示一月中的日期 ...
date.toLocaleString());//转化为本地时间 alert(date.getFullYear());//显示年份 alert(date.getMonth() + 1);//显示月份 0-11,需要加1 alert(date.getDate());//显示一月中的日期 ...
使用方法: $(document).ready(function() { //导出excel $("#output").click(function(){ var myDate = new Date(); $("#example").table2excel({ exclude: ".noExl", name: "Excel Document Name.xlsx", ...
1.第一种方法 当前时间: <td id=CurrentTime></td> [removed] function changetime(){ var ary = [星期日,星期一,星期二,星期三,星期四,星期五,星期六];...Timehtml[removed] = ''+date.toLocaleString()+'
[removed]setInterval("jnkc[removed]=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000); [removed] </body> </html> 希望本文所述对大家Java
var myDate = new Date(); $("#example").table2excel({ exclude: ".noExl", name: "Excel Document Name.xlsx", filename: myDate.toLocaleString(), exclude_img: true, exclude_links: true, exclude_...
网页特效|Linkweb.cn/Js|---...; charset=gb2312"> </head> <script>setInterval("linkweb.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000); </html>
字符串格式.js ... 支持 Date.toLocaleString() 的所有浏览器的命名日期转换(一月,二月) 支持的标志: '-':结果将左对齐。 '+':结果总是包含一个符号 ' ':结果将包含一个正值的前导空格 '
return new Date(parseInt(nS) * 1000).toLocaleString().replace(/:\d{1,2}$/,' '); } alert(getLocalTime(1293072805)); 第二种 function getLocalTime(nS) { return new Date(parseInt(nS) * 1000)....
在客户端显示一个注释. ...-- This page was loaded on (new java.util.Date()).toLocaleString() %> --> 在客户端的HTML源代码中显示为: <!-- This page was loaded on January 1, 2000 -->
utc2locale 从 Date#toUTCString() 到 Date#toLocaleString() 的流式方法。安装 $ npm install -g utc2locale用法正确运行 $ tail -f /path/to/your/log | utc2locale或者 $ utc2locale </path/to/your/log与 ...
最近做的一个项目,从后台查询到日期数据传到前台JS中遍历之后显示的是以”14″...Date.prototype.toLocaleString = function() { return this.getFullYear() + - + (this.getMonth() + 1) + - + this.getDate() + +
;font-size=15px">当前时间:<label id="aa"></label> ... setInterval("aa.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000); </script> </font>
本文实例讲述了JavaScript中toLocaleString()和toString()的区别。分享给大家供大家参考,具体如下: 《javascript高级程序设计》解释: “toLocaleString()返回对象的字符串表示,该字符串与执行环境的地区对应;...
[removed]setInterval(jnkc[removed]=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());,1000); [removed] 第二种:javascript显示当前系统时间代码 2015年12月1日 [removed] &...
feignClient中配置ribbon和hytrix 1.使用@FeignClient注解发现服务 ... System.out.println("stu-provide:localhost:5865==>消费者查询学生时间:"+new Date().toLocaleString()); Student stu = studentService.