返回列表 發帖

1231 jva102 時間

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

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

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

本帖最後由 TOM 於 2011-12-31 11:07 編輯 ! n8 R9 j$ g, X3 ^3 _! I
  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

本帖最後由 kim 於 2012-7-27 20:28 編輯 ; M: p2 J; e. J) P, h. c  g! m2 X
  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

import java.util.*; //Date( c1 X4 L$ J  x" a5 K1 ]4 C' d
import java.text.*; //SimpleDateFormat0 w1 H  p/ Y2 a5 F- J* |. o

9 U6 u% ^& x4 y* m0 Cpublic class j102{4 _# a; `, z$ G' N
' }; `1 \. x; m& N# w( |
        public static void main(String arg[]){9 L$ A: l6 \: a5 R- m- v
                    System.out.println("------------------");" E. E8 v1 `# i2 M2 E
                    System.out.println("     當地時間拉     ");2 f0 c/ m, B; d. Q% D: u
                    System.out.println("------------------");
( h  v2 C( b) u' b+ a                Date d = Calendar.getInstance().getTime();+ j3 M7 J7 f$ f' O: h
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
$ T7 C: S7 |  U7 M                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");( p0 [+ h7 Q" J& D" B
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
. f" y/ p" m4 w                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");' {. J/ S( c( k  Q; p
                System.out.println(sdf1.format(d));" ]8 D2 M) G2 Y+ m; P- j
                                System.out.println(sdf2.format(d));
2 Q" j0 [/ \4 t( a9 l8 l2 Q; F                                System.out.println(sdf3.format(d));+ C* U0 L2 j$ u: V" M- s, X
                                System.out.println(sdf4.format(d));
4 p% T- e) B9 S5 P% A- |( [+ y" Y3 ~3 R        }
7 R; H; m' e, [1 ^4 z9 [% {}
人平

TOP

import java.util.*; //Date8 x3 Z+ ~+ |1 i% n! s
import java.text.*; //SimpleDateFormat
: x' |& h$ x+ i; W! _0 R# l4 K$ M# u5 V8 ^* \+ v0 Z. [! Q
public class j102{$ v$ I- Z1 z$ r! L2 C% Q
4 i2 S: E: g8 ?
        public static void main(String arg[]){
' W5 {% O! _! K) P0 Z                    System.out.println("------------------");
6 L* d2 F( X; v& p                    System.out.println("     當地時間     ");
( T; Y# s, U1 Q; `2 R# _                    System.out.println("------------------");
5 `4 ^. R( _0 f1 \$ R+ b8 J. E                Date d = Calendar.getInstance().getTime();$ F0 S; A0 A% J! f3 w
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");  `+ W( i/ u! c) m9 {% u1 t
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");. _7 a7 W/ P, {' W  i7 H$ }
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
* c" c7 y9 J& A$ \( M                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
# P. l6 `7 k7 H7 W, K                System.out.println(sdf1.format(d));
2 M% D: [1 U6 D* w- |8 M6 a: z$ Z                                System.out.println(sdf2.format(d));
/ R) T; r5 ^  {$ o0 A; o4 `                                System.out.println(sdf3.format(d));
5 s8 f' R8 M6 B4 @, h4 I                                System.out.println(sdf4.format(d));% A9 m. s. r+ C( O6 e
        }/ ?  \+ C# @3 w
}
小雲雀

TOP

返回列表