返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date, p2 w  h( i3 t4 W2 i. K
import java.text.*; //SimpleDateFormat
1 o, ~! v; U( ^
2 @, `# ~9 N; i9 C5 m# Fpublic class j102{& j" ]# I4 k" @9 [$ y
- ?$ f4 e2 P, j6 t+ R
        public static void main(String arg[]){
" z( W* n6 }& h9 ^0 E+ a                    System.out.println("------------------");* P* J+ P9 }( {: n& y! y
                    System.out.println("     當地時間     ");
8 w6 F8 R2 R- d) d; `. T8 Q" k                    System.out.println("------------------");0 ]5 x! W5 i1 o+ w8 ~4 c
                Date d = Calendar.getInstance().getTime();5 T. d/ h: b- W4 O8 P" a
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
( I- V/ O8 {. \; w) v: o) W8 z: o                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");
1 {5 q  H: D. T1 b" n& m1 y                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");# W0 h/ B& Y! p2 Q# A! [9 G+ X  |
                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
* w; X% Q/ ^+ V: R& w                System.out.println(sdf1.format(d));
+ S$ j+ t& i7 \                                System.out.println(sdf2.format(d));. p) j2 j! A0 T) ~  A! d, y- |  Y0 N
                                System.out.println(sdf3.format(d));
" N0 F- C6 o7 ^# d' y& E                                System.out.println(sdf4.format(d));
+ u& G8 k4 b  C% N$ b) g        }
" ^( z$ N# y' i$ ]8 w# p}
小雲雀

TOP

import java.util.*; //Date
: y0 G4 E0 y* Uimport java.text.*; //SimpleDateFormat
: z3 Y% D: @& h$ m# R$ Z1 g
* }. e+ b  Z$ w! N7 {) m6 Z5 ]public class j102{
( {5 f  W' y, D2 `& }6 K, m
: u; X, a& c8 \        public static void main(String arg[]){
! j. Y! Q4 }( Z/ l, \, C! N: X7 B                    System.out.println("------------------");
7 j& Y; E* l7 [: b( W                    System.out.println("     當地時間拉     ");
0 G2 H9 V7 U/ g3 R! S. x* w0 K: i6 ]* _                    System.out.println("------------------");
/ V5 Z) X3 f6 [# S8 i* D                Date d = Calendar.getInstance().getTime();; d$ Z- D" }1 g  i6 D
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");
) _! `2 ~* Y2 O0 [* k5 D                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");+ B, q1 W1 _: |
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
( j! ]) M0 H2 \/ ^( W" e* Z                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");. c+ x4 E( N/ m7 e3 E
                System.out.println(sdf1.format(d));" G& ?6 x  D+ |& L/ E: h
                                System.out.println(sdf2.format(d));7 u: ?9 J( c( _2 C
                                System.out.println(sdf3.format(d));7 e: u; H; {) V) x7 x
                                System.out.println(sdf4.format(d));- S3 y) Q+ |: F1 a! \2 X
        }: ^: i. S$ Y$ }5 P/ Y- Y9 M. i
}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯
9 Q5 I; S2 D1 W% b5 d
  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 編輯 # U0 k: N' R& m, D. ?1 b. |
  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

返回列表