返回列表 發帖

1231 jva102 時間

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

import java.util.*; //Date8 S( l3 e3 C8 I# w6 g4 F
import java.text.*; //SimpleDateFormat
) }0 }4 [/ x; F8 M- O5 f  f9 Z3 A: p8 q. I6 \1 ?& @
public class j102{
7 W! g( W  v, u/ F
+ C8 C# P" @" p* E        public static void main(String arg[]){
* a" x4 V' c6 J, p                    System.out.println("------------------");6 j- H% u8 V3 M8 A5 b% z6 S! \
                    System.out.println("     當地時間     ");6 c' g4 m$ S# f4 P' N" E
                    System.out.println("------------------");
$ M7 N: v3 F/ [8 m! O: n                Date d = Calendar.getInstance().getTime();2 @9 B( G1 Q0 L1 g. T) ~) I
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");0 V9 l7 s$ f; y7 ^6 \1 l
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");- `+ ~; B' t9 h0 {* q, L: `1 C
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");
/ S$ Q% e, _& T8 I                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");
! K6 H; A2 {( t, C+ [* l9 B& a                System.out.println(sdf1.format(d));
' L+ Q! C  x1 p9 x/ B( Y+ r                                System.out.println(sdf2.format(d));
1 W$ Q+ T* [9 z0 A& n                                System.out.println(sdf3.format(d));- {! B8 ~) x( s
                                System.out.println(sdf4.format(d));' j) Z3 j1 Z" n; n3 _3 K  v
        }
- W2 a8 A# e4 J& l2 e6 ]9 h& [}
小雲雀

TOP

import java.util.*; //Date" N" c; _! N/ O: r$ s) k. u
import java.text.*; //SimpleDateFormat
5 p7 c5 w, ~1 |5 L# Y6 r, a$ N8 k% n* m
public class j102{( g0 U( P! f, v
% e+ a# l1 \7 A
        public static void main(String arg[]){
3 j3 O1 V! {, @& z' W2 n                    System.out.println("------------------");! K2 |: {3 W* u- M, V
                    System.out.println("     當地時間拉     ");6 V, M4 p0 n2 S+ h) {6 f
                    System.out.println("------------------");
  R% j# r" g' P2 v# F$ d: m7 s; Y                Date d = Calendar.getInstance().getTime();  I8 }3 Q% e$ Q  E) v" g
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/M/d a hh:mm");/ \4 A& x* g1 b
                                SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/M/d a hh:mm:ss");" {* z$ d: r% I2 w: x* t$ j8 `: @; K
                                SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年M月d日 ahh時mm分ss秒");2 }& Q* y# r6 ]. x8 ?! N/ [- N
                                SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年M月d日 E ahh時mm分ss秒 z");( U" Y) w4 t8 n  K) J- Y
                System.out.println(sdf1.format(d));
, C3 B) I1 Q! r- d' S* {                                System.out.println(sdf2.format(d));
, g. u( y9 s6 W( y                                System.out.println(sdf3.format(d));2 @) z5 _2 |0 V! F! f7 V! w
                                System.out.println(sdf4.format(d));" j" Y* L7 C7 z! G
        }
& {3 J% d4 t7 H9 |8 V}
人平

TOP

本帖最後由 kim 於 2012-7-27 20:28 編輯
( W6 s4 T$ J, w& i+ j+ z
  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 i1 P' v8 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

返回列表