日出星辰

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

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

          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 日出星辰 閱讀(114) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 北海市| 荔波县| 广丰县| 信宜市| 青州市| 黄龙县| 六安市| 章丘市| 兰州市| 葵青区| 兴山县| 开封市| 余干县| 汝阳县| 嵊州市| 喀喇沁旗| 伊吾县| 辽阳市| 抚顺县| 房产| 广汉市| 越西县| 阳城县| 梁平县| 东源县| 晋中市| 县级市| 漳州市| 肃北| 赤水市| 万全县| 界首市| 黔西县| 大化| 盘山县| 漳平市| 肥城市| 长沙市| 孝昌县| 鄱阳县| 莒南县|