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
3 \4 B5 b' S. E7 U+ D% r& Simport java.text.*; //SimpleDateFormat% h# ^# |9 u) g$ t8 \" e: Z- L

2 O3 m3 G7 O' B  A& L& hpublic class j102{1 N5 T# |) M) x+ N1 c4 D5 W
  O  ~! k0 `/ F3 G3 i, ]
        public static void main(String arg[]){5 r! x0 F6 R- n
                    System.out.println("------------------");
. W* Z& o8 w+ Y) }- a3 O                    System.out.println("     當地時間     ");
6 z7 s) ?- I2 w- }! A                    System.out.println("------------------");" H& {: b+ I7 K- a
                Date d = Calendar.getInstance().getTime();
' S2 T9 n- H5 b7 C* l, e                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
8 [1 t. [1 A! [- H  S1 m                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
* w. t0 n0 u/ i! u                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
: l/ x5 U  ~  g1 B* c                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");$ f8 Q6 R& @3 V( c- r: w( \
                System.out.println(sdf1.format(d));+ `6 b0 q% F6 T$ B  y& q
                                System.out.println(sdf2.format(d));
3 h, N. W# n  G  B( ~/ X                                System.out.println(sdf3.format(d));+ [$ E2 X+ X, W
                                System.out.println(sdf4.format(d));9 ]  S  e9 d! i; m5 q9 s1 E4 R
        }4 [2 O. w# {. F' [' X% h) }
}
作者: eric5802    時間: 2011-12-31 10:45

import java.util.*; //Date' h; Y1 r/ ^* L4 \+ x
import java.text.*; //SimpleDateFormat  f, l* I$ U; V/ G
' r* n7 [: S# `8 X$ W
public class j102{0 L- x( h* c3 b7 Q

/ Y: A5 ?0 I4 [2 G3 t        public static void main(String arg[]){* a4 A8 `4 z( u1 I  V/ Z
                    System.out.println("------------------");1 V' x6 [5 ^& Q9 f0 U
                    System.out.println("     當地時間拉     ");
# _$ m; Y* x4 F8 m$ m                    System.out.println("------------------");
5 N2 R& w$ O! G8 ~$ w+ b1 F                Date d = Calendar.getInstance().getTime();) P% n5 l" ]; a6 K
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
# R. p( [! a) A/ J. Y) _6 F                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
5 b) g1 C: u2 {( K5 F% @1 i                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
) z3 o% O+ |& P- V  ~                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");) c, z7 X$ h0 K7 @+ o! _: i+ o( K
                System.out.println(sdf1.format(d));4 h' L7 Q- R' H: Q) ^" |
                                System.out.println(sdf2.format(d));9 q* K/ z' C. ^3 h; a- M
                                System.out.println(sdf3.format(d));4 C" X7 j, r) z' B9 M+ o
                                System.out.println(sdf4.format(d));/ B& g8 x; A! L  m! s: I7 d3 D+ ^& q
        }( _9 E- h& S+ d, f7 k/ N8 U
}
作者: kim    時間: 2011-12-31 10:46

本帖最後由 kim 於 2012-7-27 20:28 編輯 1 r% d/ e! k! ]* O% |5 O; r
  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 編輯
: O9 u# e( X+ S+ L
  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