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)
+ " 微秒");
}
}

你可能感兴趣的:(java,应用,java,数据库)