﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-softzhi</title><link>http://www.blogjava.net/softzhi/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 15:03:39 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 15:03:39 GMT</pubDate><ttl>60</ttl><item><title>java中常见的日期时间类 以及时间转换</title><link>http://www.blogjava.net/softzhi/archive/2008/05/06/198654.html</link><dc:creator>支得柱</dc:creator><author>支得柱</author><pubDate>Tue, 06 May 2008 03:39:00 GMT</pubDate><guid>http://www.blogjava.net/softzhi/archive/2008/05/06/198654.html</guid><wfw:comment>http://www.blogjava.net/softzhi/comments/198654.html</wfw:comment><comments>http://www.blogjava.net/softzhi/archive/2008/05/06/198654.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/softzhi/comments/commentRss/198654.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/softzhi/services/trackbacks/198654.html</trackback:ping><description><![CDATA[<h2>java中常见的日期时间类 以及时间转换</h2>
<div id="postmessage_747403" class="t_msgfont">最近做项目用到时间的地方可以看看。<br />
<br />
java中常见的日期时间类<br />
&nbsp;&nbsp;Date 类 最基础的日期时间类，返回一个相对日期的毫秒数。<br />
&nbsp;&nbsp;DateFormat类 可以接受字符串输入 输出<br />
&nbsp;&nbsp;SimpleDateFormat类 功能更强大的日期时间格式化类<br />
&nbsp;&nbsp;GregorianCalendar类 提供处理日期的方法，用于计算日期<br />
&nbsp;&nbsp;Calender类<br />
转换字符串为日期<br />
String strDate = "2004-08-13";<br />
SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");<br />
Date sDate = sDateFormat.parse(strDate);<br />
获得当前时间<br />
GregorianCalendar thisday = new GregorianCalendar();<br />
格式化显示日期型数据<br />
Date dt_in ：日期型数据<br />
boolean bShowTimePart_in ： 是否显示时间部分<br />
@return String 格式化后的日期格式<br />
*/<br />
public String DoFormatDate(java.util.Date dt_in, boolean bShowTimePart_in) {<br />
if (bShowTimePart_in)<br />
&nbsp;&nbsp;return (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(dt_in);<br />
else<br />
&nbsp;&nbsp;return (new SimpleDateFormat("yyyy-MM-dd")).format(dt_in);<br />
}<br />
获得当前日期和时间<br />
import java.util.*;<br />
&nbsp;&nbsp;public String GetCurTime()//获得当前时间<br />
&nbsp;&nbsp;{<br />
&nbsp; &nbsp; Date now=new Date();<br />
&nbsp; &nbsp; return now.getHours()+":"+now.getMinutes()+":"+now.getSeconds();<br />
&nbsp;&nbsp;}<br />
&nbsp;&nbsp;public String GetCurDate()//获得当前日期<br />
&nbsp;&nbsp;{<br />
&nbsp; &nbsp; Calendar cal=Calendar.getInstance();<br />
&nbsp; &nbsp; return cal.get(Calendar.YEAR)+"年"+(cal.get(Calendar.MONTH)+1)+"月"+cal.get(Calendar.DATE)+"日";<br />
&nbsp;&nbsp;}<br />
<br />
//字符串转化为日期字符串20050412-&gt;2005-04012<br />
public String FormatDateStr(String Str){<br />
&nbsp; &nbsp;&nbsp;&nbsp;try {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;String bb="";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;int num=8-Str.length();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for(int i=0;i&lt;num;i++)//不足8位要补足8位<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Str="0" + Str;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;String str1=Str.substring(0,4);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1+"-";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;str1=Str.substring(4,6);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1+"-";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;str1=Str.substring(6,8);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return bb;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;catch (Exception e)<br />
&nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp; return "";<br />
&nbsp; &nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp;}<br />
////字符串转化为时间字符串130416－&gt;13:04:16<br />
&nbsp;&nbsp;public String FormatTimeStr(String Str){<br />
&nbsp; &nbsp;&nbsp;&nbsp;try {<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;String bb="";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;int num=6-Str.length();<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for(int i=0;i&lt;num;i++)//不足6位要补足6位51325-&gt;05:13:25<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Str = "0" + Str;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;String str1=Str.substring(0,2);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1+":";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;str1=Str.substring(2,4);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1+":";<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;str1=Str.substring(4,6);<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;bb=bb+str1;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return bb;<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }<br />
&nbsp; &nbsp;&nbsp; &nbsp;catch (Exception e)<br />
&nbsp; &nbsp;&nbsp; &nbsp;{<br />
&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;return "";<br />
&nbsp; &nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp;}</div>
<img src ="http://www.blogjava.net/softzhi/aggbug/198654.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/softzhi/" target="_blank">支得柱</a> 2008-05-06 11:39 <a href="http://www.blogjava.net/softzhi/archive/2008/05/06/198654.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> spring asm出错的解决方案</title><link>http://www.blogjava.net/softzhi/archive/2008/05/06/198640.html</link><dc:creator>支得柱</dc:creator><author>支得柱</author><pubDate>Tue, 06 May 2008 01:55:00 GMT</pubDate><guid>http://www.blogjava.net/softzhi/archive/2008/05/06/198640.html</guid><wfw:comment>http://www.blogjava.net/softzhi/comments/198640.html</wfw:comment><comments>http://www.blogjava.net/softzhi/archive/2008/05/06/198640.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/softzhi/comments/commentRss/198640.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/softzhi/services/trackbacks/198640.html</trackback:ping><description><![CDATA[<p><font style="background-color: #c7edcc">发现整合进 web 时就报如下的错误:</font></p>
<p><font style="background-color: #c7edcc">2007-08-08 15:36:17,406 ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: dao.User<br />
java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V<br />
&nbsp;at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)</font></p>
<p><font style="background-color: #c7edcc">Spring 和 Hibernate 共用的一些 jar 文件发生了版本冲突, 删除 asm-2.2.3.jar.</font></p>
<p><font style="background-color: #c7edcc">asm-2.2.3.jar<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asm.jar<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asm-attrs.jar<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asm-commons-2.2.3.jar<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; asm-util-2.2.3.jar</font></p>
<img src ="http://www.blogjava.net/softzhi/aggbug/198640.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/softzhi/" target="_blank">支得柱</a> 2008-05-06 09:55 <a href="http://www.blogjava.net/softzhi/archive/2008/05/06/198640.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>