返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date" O, ~/ V. k6 A. t+ h: ~' a) t
import java.text.*; //SimpleDateFormat
6 q% z& F+ k0 V7 B3 {  n
( ?8 K$ C( L4 Q8 |8 v, Upublic class j102{
+ j' D% Q& f) T% P8 I1 z- A- x# R' _/ J, W" T6 R3 O% Q3 S! p
        public static void main(String arg[]){
$ @& _  v& w8 P0 R  s# q2 V. S# n                    System.out.println("------------------");* U& G" v5 q  E8 v. M: q9 }8 N
                    System.out.println("     當地時間     ");' f8 G0 {- ^6 N  u+ w* W
                    System.out.println("------------------");
; P& H, W; h" q( d                Date d = Calendar.getInstance().getTime();
3 G5 u" Y& Z3 y7 h& w                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");3 h' @1 Q4 c. c' V( ]# {0 K: \
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");9 j+ z( r* ^$ D; k' |
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
7 \& `1 o6 T% j* L- k3 C% I: m                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");7 C# v& S% |, h$ l( g1 H. a' |/ U
                System.out.println(sdf1.format(d));4 Y7 C3 O4 ]: @# U+ l6 O
                                System.out.println(sdf2.format(d));4 c. i* a5 g1 H$ h  N  X
                                System.out.println(sdf3.format(d));/ S$ V* Z( V: x2 B1 t9 w) U4 |
                                System.out.println(sdf4.format(d));1 L5 _; C" Y. c+ C! d2 X: G
        }, Z. o0 ?1 K% [7 O
}
小雲雀

TOP

import java.util.*; //Date
* f6 S7 n0 u1 Qimport java.text.*; //SimpleDateFormat
1 i/ B" |! n$ M3 _" j, z& d/ p2 k% k2 e& |5 |
public class j102{& p' r+ N- e8 E

% B8 ^4 M; N2 `7 v8 `5 U3 a3 y        public static void main(String arg[]){$ y; R% c7 I* Q0 Q* _2 d4 x
                    System.out.println("------------------");: _$ G9 c$ ^- c
                    System.out.println("     當地時間拉     ");
6 _* H6 T. j; E9 j$ t- [" n3 Z                    System.out.println("------------------");5 O1 r6 M# s" s/ K) k8 ^
                Date d = Calendar.getInstance().getTime();
8 `0 e" R& X: K                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");5 H1 c% q  n' E4 a; K: l
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
  P( B' n( X. }  c( U                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
, \; C2 m. w# J0 V+ A$ d. O                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
; u2 c2 {8 G7 U, J- O1 [# @! y+ U                System.out.println(sdf1.format(d));0 J8 p  U  W9 I/ r& l* W! b* m2 T
                                System.out.println(sdf2.format(d));
& r4 z; Q  W9 ]. c, D                                System.out.println(sdf3.format(d));
) y8 e1 q" h1 d6 n4 `                                System.out.println(sdf4.format(d));
; Z& L, y+ D; E        }0 `7 C! k2 p& Z4 Z4 j" ^
}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯 + J) K) c8 D- h( w7 ]
  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 編輯 7 E$ X) v0 Q* l* G
  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

返回列表