Java获取当前时间并转化成字符串

package com.happy.sqlite.test;

import java.util.Calendar;

public class LostTime2 {
public static void main(String[] args) {
long now = System.currentTimeMillis(); // 排序前取得当前时间
Calendar c = Calendar.getInstance();
c.setTimeInMillis(now);

System.out.println("当前时间: " + c.get(Calendar.YEAR) + "年 "
+ (c.get(Calendar.MONTH) + 1) + "月 " + c.get(Calendar.DATE)
+ "日 周" + (c.get(Calendar.DAY_OF_WEEK) - 1) + " "
+ c.get(Calendar.HOUR) + "时 " + c.get(Calendar.MINUTE) + "分 "
+ c.get(Calendar.SECOND) + "秒 " + c.get(Calendar.MILLISECOND)
+ " 微秒");
}
}

 

posted on 2011-12-14 16:04  快乐每一天Joe  阅读(1628)  评论(0编辑  收藏  举报

导航