返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date
2 F2 T3 C( y1 s- ]: Ximport java.text.*; //SimpleDateFormat
3 X: E! a/ M) b  y
( D& q( M3 o* O, s6 upublic class j102{
3 J2 K) i4 c; R5 B5 i1 {* e5 u& a
- z& D& C# G0 L% G( l6 ^        public static void main(String arg[]){
2 `8 X* f/ O* f+ ]& b, b; P                    System.out.println("------------------");
( B6 C  O" P# w( S' e' W                    System.out.println("     當地時間     ");
) w* ]4 l' P" Z( k                    System.out.println("------------------");: s6 b8 N, K4 |) e8 s* ^3 k) ^. n
                Date d = Calendar.getInstance().getTime();' `; f, P+ N' r6 Y
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
. n& Q$ d1 l& ~; S; F) \9 N5 X                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
- o5 c2 O: f# K* |' u6 s) ^3 A( i                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
1 f& w, Y1 b7 N! t& @                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");" J; J( i$ z! D3 C0 z" k( @
                System.out.println(sdf1.format(d));; C* \: }5 N1 y
                                System.out.println(sdf2.format(d));
( ^5 |+ P3 a& G                                System.out.println(sdf3.format(d));1 ]# Z. H; M' w# ~$ I( M
                                System.out.println(sdf4.format(d));
0 @+ n0 _; {4 c3 D' E) J7 l! d        }
- J6 C) P7 n8 c; F}
小雲雀

TOP

import java.util.*; //Date
! a6 M# n9 R# b/ z& ?; rimport java.text.*; //SimpleDateFormat
! w% Z$ W& O) ^+ M; @. q- w% D
public class j102{
/ |; L6 v0 O* i) l; b1 z2 }* ?
% |. H9 s# D% d" M6 h$ u$ a; A* O6 Q        public static void main(String arg[]){
( W" [/ D& N4 G) ^. h: t& T) x                    System.out.println("------------------");
( {7 k6 R) p+ `0 I, g# N! @                    System.out.println("     當地時間拉     ");8 v( k7 @, `0 K' m, u2 ?- M- R! L7 ?+ h
                    System.out.println("------------------");  d0 [9 A7 V  L  g$ s* i; S
                Date d = Calendar.getInstance().getTime();
: `: x6 V5 O4 e4 O8 r3 a                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");$ d" V) _# T; H- U# D
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");2 T/ a# A6 \, Z9 r7 j5 z2 I5 e
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
' u  ^) E0 m2 e/ L, h                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");. ^+ M, z; ^) ~8 w% C' G
                System.out.println(sdf1.format(d));2 o/ l0 t4 x, h0 r
                                System.out.println(sdf2.format(d));$ B7 E1 u- ?. i$ R* \$ f7 E7 l% j
                                System.out.println(sdf3.format(d));. Z" E4 k9 m0 v) C8 H
                                System.out.println(sdf4.format(d));1 n; q/ y" F8 K% ^" [$ d; ~
        }( q% S* v: j. x0 v( X3 k/ p6 W0 D
}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯 ; v- ?& @& |8 ~7 H& b! G
  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 編輯
2 F% B& y( f! v* Q$ m5 g1 j6 o
  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

返回列表