天空是藍(lán)色的

          做好軟件為中國 #gcc -c helloworld.c -o helloworld.o //編譯目標(biāo)文件 #gcc helloworld.o -o helloworld //編譯成可執(zhí)行exe #helloworld //運行exe
          數(shù)據(jù)加載中……
          Java.util.Date類型格式化輸出和字符串轉(zhuǎn)Date類型
           1 import java.text.Format;
           2 import java.text.ParseException;
           3 import java.text.SimpleDateFormat;
           4 import java.util.Date;
           5 
           6 public class DateFormatToString {
           7     protected static Format format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
           8 
           9     public static void main(String[] args) {
          10 
          11         Date date = new Date();
          12         System.out.println(format.format(date));
          13 
          14         try {
          15             Date date1 = (Date) format.parseObject("2005-11-15 20:55:48");
          16             System.out.println(date1);
          17         } catch (ParseException e) {
          18             // TODO Auto-generated catch block
          19 
          20         }
          21 
          22         format = new SimpleDateFormat("yyyy-MM-dd");
          23         System.out.println(format.format(date));
          24         format = new SimpleDateFormat("hh:mm:ss");
          25         System.out.println(format.format(new Date()));
          26 
          27     }
          28 }

          輸出
          12005-11-15 09:02:30
          2Tue Nov 15 20:55:48 CST 2005
          32005-11-15
          409:02:30

          posted on 2005-11-16 16:59 bluesky 閱讀(7616) 評論(0)  編輯  收藏 所屬分類: 基礎(chǔ)知識

          主站蜘蛛池模板: 常德市| 武川县| 泌阳县| 塔城市| 赣州市| 西乡县| 平湖市| 台湾省| 泸定县| 昌都县| 新巴尔虎左旗| 黔江区| 资源县| 夏津县| 长白| 车致| 安图县| 荣昌县| 内乡县| 全椒县| 霍林郭勒市| 远安县| 太仆寺旗| 林芝县| 三门县| 西乌珠穆沁旗| 洛川县| 宁陵县| 台中县| 华池县| 松原市| 荔浦县| 前郭尔| 遂昌县| 长沙县| 平南县| 马龙县| 永登县| 新竹县| 延边| 湘西|