返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date
( Y  U& G& e4 b3 B& Q) S3 ximport java.text.*; //SimpleDateFormat
. ~3 Z/ I! y! x: g- c& @
) h8 E  j8 x% V# n  a0 Y) Apublic class j102{  K; V/ J) ^6 s; f+ t) H
6 l" e0 D0 |0 E& f: x; r
        public static void main(String arg[]){
9 h. n# c0 w1 E8 d                    System.out.println("------------------");" v( X( ]8 _6 t4 P- R, c
                    System.out.println("     當地時間     ");
. E- l; |5 n6 M8 m                    System.out.println("------------------");$ `% ^" P; _, S& c
                Date d = Calendar.getInstance().getTime();# m) @( W; D$ f, G& V3 Q  C
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
9 V$ @# Q6 o8 X, ^. }. ]                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
* A3 U/ T, K' g; H2 ?$ z                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");9 G$ H5 B: P5 j- e
                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");5 f- R5 l( ?( \5 G  S9 e# U9 E* U
                System.out.println(sdf1.format(d));3 }8 A/ B+ S4 N, Q: R( d+ Y. o& u
                                System.out.println(sdf2.format(d));  t2 O8 J* \+ N8 h1 n" L# p! L
                                System.out.println(sdf3.format(d));
! Z7 Q% |# k6 v0 M: e                                System.out.println(sdf4.format(d));
' q3 e( B% p( z: O$ @        }
3 y% L. \# i4 e) y' A}
小雲雀

TOP

import java.util.*; //Date) ^0 ^6 r" ~6 i- J. b" a
import java.text.*; //SimpleDateFormat
1 o4 h; e7 {  J7 Z  D8 v; z( {
; b. I4 c# G8 d5 d6 g$ Jpublic class j102{
! |% p9 o1 v" f2 k4 E  I, `2 f, i; y" I# X! d3 q! t
        public static void main(String arg[]){
, b: @9 ?4 P  d0 `                    System.out.println("------------------");
/ d& Q' |5 I1 l9 y0 H1 w                    System.out.println("     當地時間拉     ");
' b) ]2 c; w, H+ C) d3 a0 W! R                    System.out.println("------------------");# z. A/ |" ]3 B" y6 U
                Date d = Calendar.getInstance().getTime();! h9 \( J6 D/ M
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");6 h$ C* k4 E. j
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
1 J# e4 X8 P$ k3 E2 D: A" p                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
9 v2 S" D$ u1 p) Z; a                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");( o6 i- V+ j6 W4 R7 ]) W: V) x
                System.out.println(sdf1.format(d));3 z' K9 S: @2 U
                                System.out.println(sdf2.format(d));
% D2 b; ]( ]' m4 Q: \                                System.out.println(sdf3.format(d));  j/ v4 E' I! h# o  w) }7 u
                                System.out.println(sdf4.format(d));
! q" Z) b9 q' Y% L1 E6 V        }
9 Q& b1 h( S  Y9 Q: ^& D}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯
& Q8 V5 f- c  `
  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 編輯
8 L  M. k0 _4 [  Q/ `6 w
  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

返回列表