日出星辰

          不同格式的日期字符串轉換

            先把字符串日期轉換成對應的格式,然后再轉換成日期

          public static void main(String args[]){
          		 String str="2010/05/06";
          		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
          		 try {
          			 str=str.replace("/", "-");
          			 System.out.println("str="+str);
          			System.out.println("time="+sdf.parse(str));
          			System.out.println("formateTime="+sdf.format(sdf.parse(str)));
          		} catch (ParseException e) {
          			e.printStackTrace();
          		}
          	 }
          

          結果:

          str=2010-05-06
          time=Thu May 06 00:00:00 CST 2010
          formateTime=2010-05-06

           

          posted on 2011-08-23 14:44 日出星辰 閱讀(111) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 饶河县| 襄樊市| 南岸区| 大厂| 白水县| 黄陵县| 罗源县| 六盘水市| 天津市| 于都县| 紫金县| 日土县| 泸水县| 疏附县| 疏勒县| 腾冲县| 紫金县| 昭平县| 平邑县| 成武县| 石家庄市| 涿鹿县| 筠连县| 信阳市| 尤溪县| 景东| 新乡市| 印江| 荃湾区| 恩施市| 裕民县| 民权县| 昌都县| 泽州县| 荥阳市| 巫溪县| 永登县| 南开区| 浮山县| 嫩江县| 栖霞市|