java獲得以後日期應用實例。本站提示廣大學習愛好者:(java獲得以後日期應用實例)文章只能為提供參考,不一定能成為您想要的結果。以下是java獲得以後日期應用實例正文
package com.infomorrow.dao;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.TimeZone;
import org.junit.Test;
public class test_date {
@Test
public void test(){
Timestamp today = new Timestamp(Calendar.getInstance(TimeZone.getTimeZone("GMT+8")).getTimeInMillis());
int year=today.getYear()+1900;
int month=today.getMonth()+1;
int day = today.getDate();
String date = year+"-"+month+"-"+day;
System.out.println("date:"+date);
System.out.println(today);
}
}
//輸入
date:2013-12-17
2013-12-17 13:04:30.809