Board logo

標題: 1231 jva102 時間 [打印本頁]

作者: b790113g    時間: 2011-12-31 09:56     標題: 1231 jva102 時間

  1. Date d = Calendar.getInstance().getTime();
  2. SimpleDateFormat sdf1=new ("yyyy");
  3. System.out.println(sdf1.format(d));
複製代碼

作者: johnson    時間: 2011-12-31 10:44

import java.util.*; //Date
# j+ U/ B7 r* Y# G4 f! mimport java.text.*; //SimpleDateFormat6 t9 i1 H. K! p% N" `; g. T

0 T5 Y' E4 I- e9 Tpublic class j102{
' p% Q& S. p* K$ X% D* c( Z) P, W1 C
        public static void main(String arg[]){
1 _9 p: i+ H( U                    System.out.println("------------------");
+ Q4 t6 Z0 P+ S( I7 U                    System.out.println("     當地時間     ");2 F, X6 J' w% b. V3 {- a
                    System.out.println("------------------");9 u  r7 t0 ~/ p
                Date d = Calendar.getInstance().getTime();
$ q/ Z6 a* R1 H6 S                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");4 {8 w5 ~  r/ |5 G/ C8 O
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");0 ?) B% r# ~: V! d4 F! {
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
7 G' B+ E# d9 }( L$ a. M" x                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
; G9 w" q) j6 c: z2 r. m  i                System.out.println(sdf1.format(d));
% v3 n5 Z% e' }6 g1 {; w+ O* l2 y                                System.out.println(sdf2.format(d));
3 ], K2 L) g+ l& |                                System.out.println(sdf3.format(d));
( _4 y: E* A: G' m2 U1 M! F! u                                System.out.println(sdf4.format(d));4 o3 i0 o1 v5 ^$ K8 C4 v3 s0 y" Q
        }
* |. G& g9 T# j9 y% \! m) _, b& f}
作者: eric5802    時間: 2011-12-31 10:45

import java.util.*; //Date
* U) r; k, m. [$ b3 n! P/ timport java.text.*; //SimpleDateFormat' t  B7 A2 e, b% u  m5 C

; H/ ]3 H( s, t0 T1 qpublic class j102{
2 i  j4 Y8 L3 o0 @
' k( a5 H6 y6 S) N+ B4 ?+ K% Q        public static void main(String arg[]){1 L. `1 b; D1 o8 ^
                    System.out.println("------------------");$ K0 [  D" Y4 r! ~0 f
                    System.out.println("     當地時間拉     ");" r* u# o8 |# u$ }( I8 @
                    System.out.println("------------------");
) ~' U& ~) P  v( ?/ V                Date d = Calendar.getInstance().getTime();
, K0 p8 z5 [! \# T2 W                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
% Y. O& k9 Q" G9 a% F. s# h                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
3 O% u" I; E- D+ n5 H# e3 B                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
6 F4 s# E. [- A, @3 L' a                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
+ |1 m' s) v, S4 m/ _/ c  Z% z4 X                System.out.println(sdf1.format(d));
1 h/ }; J* I" ?) ~% l6 d6 k1 K) [                                System.out.println(sdf2.format(d));
; h3 W! B% [  E5 j2 K# @                                System.out.println(sdf3.format(d));/ g9 [7 O( B9 i7 Y: _5 N8 C. W, g
                                System.out.println(sdf4.format(d));
; w+ O4 g0 e# F" _        }
9 N; n+ ^; H# e2 ]/ V4 P- h' q- j}
作者: kim    時間: 2011-12-31 10:46

本帖最後由 kim 於 2012-7-27 20:28 編輯 ! t$ A! t8 J) ?9 z* }
  1. import java.util.*; //Date
  2. import java.text.*; //SimpleDateFormat

  3. public class j102{

  4.         public static void main(String arg[]){
  5.                 System.out.println("------------------");
  6.                 System.out.println("     當地時間     ");
  7.                 System.out.println("------------------");
  8.                 Date d = Calendar.getInstance().getTime();
  9.                 SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
  10.                 SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
  11.                 SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
  12.                 SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
  13.                 System.out.println(sdf1.format(d));
  14.                 System.out.println(sdf2.format(d));
  15.                 System.out.println(sdf3.format(d));
  16.                 System.out.println(sdf4.format(d));
  17.         }
  18. }
複製代碼

作者: TOM    時間: 2011-12-31 10:52

本帖最後由 TOM 於 2011-12-31 11:07 編輯 3 k7 b- f! a4 R
  1. import java.util.* ;
  2. import java text.*;
  3. public class j103
  4. {
  5.         public static void main(Sting[]arg)
  6.         {
  7.                 System.out.println("------------------");
  8.                     System.out.println("     當地時間拉     ");
  9.                     System.out.println("------------------");

  10.         Date d=Calendar.getInstance.getTime();
  11.         SimpeDateFormat sdf1=new SimpeDateFormat("yyyy/M/d a hh:mm")
  12.         SimpeDateFormat sdf2=new SimpeDateFormat("yyyy/M/d a hh:mm:ss")
  13.         SimpeDateFormat sdf3=new SimpeDateFormat("yyyy年M月d日 ahh時mm分ss秒")
  14.         SimpeDateFormat sdf4=new SimpeDateFormat("yyyy年M月d日 E ahh時mm分ss秒")
  15.        
  16.         System.out.println(sdf1.fotmat(d));
  17.         System.out.println(sdf2.fotmat(d));
  18.         System.out.println(sdf3.fotmat(d));
  19.         System.out.println(sdf4.fotmat(d));
  20.         }
  21. }       
複製代碼

作者: may    時間: 2011-12-31 11:21

  1. import java.util.*; //Date
  2. import java.text.*; //SimpleDateFormat
  3. public class jva102{
  4.         public static void main(String arg[]){
  5.                 //Date d = new Date(); //新產生物件 可指定時間 () 內可帶參數
  6.                 // 取得日曆物件裡的實際系統時間
  7.                 Date d = Calendar.getInstance().getTime();
  8.                 //基本日期格式化
  9.                                 System.out.println("        當地時間");
  10.                 System.out.println("-------------------------");
  11.                                 SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
  12.                 SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
  13.                 SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 a hh時mm分ss秒");
  14.                 SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E a hh時mm分ss秒 z");
  15.                 System.out.println(sdf1.format(d));
  16.                                 System.out.println(sdf2.format(d));
  17.                                 System.out.println(sdf3.format(d));
  18.                                 System.out.println(sdf4.format(d));
  19.                                
  20.         }
  21. }
複製代碼

作者: lon    時間: 2012-1-7 09:58

[attach]567[/attach]




歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2