获取到当前系统的日期后,结果是5/9/2007
如何让结果变成05/09/2007 14:05呢???
如何让结果变成05/09/2007 14:05呢???
解决方案 »
- 请教!关于ObjectInputStream的问题!
- JAVA如何获取Socket绑定的设备名称
- inputstream类的read方法返回值代表什么意思?
- 按逻辑,我的这判断应该等于10,11,12,13,14,15的数组呀?怎么不对?
- 一个重定向的问题。
- 在java里面如何把2进制专成8进制,或者10进制,有具体的函数么
- 怎样把字符串放在TextField的右边显示???
- 我想把一个表里的数据拿出来,转换成xml格式,通过网络传到另外的数据消费者,如何设计xml的格式
- 在一个应用程序中我用new String(str.getBytes("ISO8859_1"),""GBK)来转换字符,运行时却报UnsupportedEncodingException: GBK错误。什么
- 请问tomcat的classpath在那个文件中设置?
- J2SE是什么
- JAVA 时间相减问题---->高手支招
A pattern of special characters is used to specify the format of the time. This example demonstrates some of the characters. For a complete listing, see the javadoc documentation for the SimpleDateFormat class.
Note: This example formats dates using the default locale (which, in the author's case, is Locale.ENGLISH). If the example is run in a different locale, the text (e.g., month names) will not be the same. Format formatter;
// The hour (1-12)
formatter = new SimpleDateFormat("h"); // 8
formatter = new SimpleDateFormat("hh"); // 08
// The hour (0-23)
formatter = new SimpleDateFormat("H"); // 8
formatter = new SimpleDateFormat("HH"); // 08
// The minutes
formatter = new SimpleDateFormat("m"); // 7
formatter = new SimpleDateFormat("mm"); // 07
// The seconds
formatter = new SimpleDateFormat("s"); // 3
formatter = new SimpleDateFormat("ss"); // 03
// The am/pm er
formatter = new SimpleDateFormat("a"); // AM
// The time zone
formatter = new SimpleDateFormat("z"); // PST
formatter = new SimpleDateFormat("zzzz"); // Pacific Standard Time
formatter = new SimpleDateFormat("Z"); // -0800
// Get today's date
Date date = new Date();
// Some examples
formatter = new SimpleDateFormat("hh:mm:ss a");
String s = formatter.format(date);
// 01:12:53 AM
formatter = new SimpleDateFormat("HH.mm.ss");
s = formatter.format(date);
// 14.36.33参考:http://www.javaref.cn/egs/java.text/pkg.html
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm");
System.out.println("At the tone, the time is " + df.format(now));
?
用simpledateformat 格式化。。
Top
回复人:wuheng66888(吴恒) ( 二级(初级)) 信誉:100 2007-05-29 14:16:19 得分:0
?
Date now = new Date();
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm");System.out.println("At the tone, the time is " + df.format(now));--------
同意
String str ="5/9/2007";
System.out.println(str.replaceAll("\\d/", "0$0"));
<input name="starttime" type="text" value=<%=month+"/"+day+"/"+year+"----"+hour+":"+minute%> maxlength="50" readonly="true">
<%!
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH)+1; //正常显示的月
int day = cal.get(Calendar.DATE); //正常显示的日
int hour= cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
int mon = cal.get(Calendar.MONTH)+1;//月
int daya = cal.get(Calendar.DATE);//日
int dayadd=7;//加的7天
int date=daya+dayadd;//判断是否大于31
String monn=null,da=null; %>
<%
if(month<10 && day<10){
monn="0"+String.valueOf(month);
da="0"+String.valueOf(day);
%>
<input name="starttime" type="text" value=<%=monn+"/"+da+"/"+year+"----"+hour+":"+minute%> maxlength="50" readonly="true">
<%}%>
再用simpledateformat格式化就可以了啊 不用那么麻烦去自己写日期的格式
joejoe1991() 这位.如何能联系到你呢...QQ.MSN.Skype..