返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date5 X# q4 t1 k  Z1 n6 S
import java.text.*; //SimpleDateFormat, ~' i& H; M4 b% U+ F

. g5 N" j% ?' j. i6 ~' p: `public class j102{
6 z4 |$ L4 |0 x; M+ o
2 y$ H0 l; g' \1 X9 ?+ U( _! E        public static void main(String arg[]){
0 R5 E# v0 h0 X' d- a                    System.out.println("------------------");
8 \) Z& g( c! ]/ a" d) Z                    System.out.println("     當地時間     ");% b0 Y) t9 G6 A: U
                    System.out.println("------------------");
7 a/ u" M. U9 r4 Q7 _9 o7 g- ]                Date d = Calendar.getInstance().getTime();3 d$ k. ~/ l5 Z8 _
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");! m. G0 S; x- f7 H) q) d
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");/ B3 K. Q/ j: j4 }6 e
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
8 T9 c/ _2 \& z" `$ ~                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
9 w' _9 Z7 w2 M! V/ r8 L                System.out.println(sdf1.format(d));$ n! I" H/ S$ L( J
                                System.out.println(sdf2.format(d));" w  s* D3 u) o% Z: s* Q5 D
                                System.out.println(sdf3.format(d));3 T: l/ N+ Y1 Z! F
                                System.out.println(sdf4.format(d));
. p/ y' G9 ?3 I0 e- y( E        }3 l! S' ?! z, ?! j( b
}
小雲雀

TOP

import java.util.*; //Date" i0 r3 a6 u6 h
import java.text.*; //SimpleDateFormat
6 d) D0 I1 T4 _( }1 I6 B( K
5 E, `: ^4 \$ S$ a' Qpublic class j102{8 p+ o! G- v+ P5 Y
. ~9 z6 e% u( u& V0 q: N
        public static void main(String arg[]){7 F) h+ m( ]1 w+ x3 V/ i
                    System.out.println("------------------");/ I. [' w7 }' R5 y% u- Y& H
                    System.out.println("     當地時間拉     ");
& P5 R1 x+ A7 o; b- F% |! o                    System.out.println("------------------");
% f' `- b+ C3 ~0 @* g( Z7 p! T                Date d = Calendar.getInstance().getTime();
5 x6 ?' o- l! h" a0 `# c                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
) }' f# n; |& R( `. l6 p                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");6 E; G3 O& U. P" S
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");- n1 G; }/ }4 A; ]- Z$ ?
                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
  N$ N" }" }/ G3 E* }                System.out.println(sdf1.format(d));) Y3 @& `: X' T( K' g4 @, H3 Y
                                System.out.println(sdf2.format(d));
* R5 f. ?" m+ L' i) c  g# k9 _* r$ L                                System.out.println(sdf3.format(d));
" o+ W# u- y, Y7 W3 a                                System.out.println(sdf4.format(d));
: p4 L  a. |; O2 @3 z6 N" `        }
: W+ [  c0 _- E+ L- B}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯
* i: ]( z. G3 o" o
  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. }
複製代碼
★ 嘉凱~~☆

TOP

本帖最後由 TOM 於 2011-12-31 11:07 編輯 ' _$ G* e+ N- r8 W5 e: @# u3 l2 j
  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. }       
複製代碼
水桶小鄭,鯰魚

TOP

  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. }
複製代碼
May

TOP

附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊
陳彥綸

TOP

返回列表