日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java 当前时间格式_java 处理时间的各种方式——获取时间——时间格式化

發布時間:2024/9/27 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 当前时间格式_java 处理时间的各种方式——获取时间——时间格式化 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

packagecom.snow;importjava.text.DateFormat;importjava.text.ParseException;importjava.text.SimpleDateFormat;importjava.util.Date;public classTimeUtil {/*** 獲取當前時間 格式為 2016-06-16 10:32:53

*

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:27*/

public staticString getCurrentTimeSceond() {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String time=format.format(newDate());returntime;

}/*** 獲取當前時間 加10分鐘 格式為 2016-06-16 10:42:53

*

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:32*/

public staticString getAfterTenTimeSceond() {long currentTime = System.currentTimeMillis() + 10 * 60 * 1000;

Date date= newDate(currentTime);

DateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String nowTime=df.format(date);returnnowTime;

}/*** 獲取當前時間的 時分 格式為 2016-06-16 10:32

*

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:39*/

public staticString getCurrentTimeMinute() {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd HH:mm");

String time=format.format(newDate());returntime;

}/*** 獲取當前時間 年月 格式為 2016-06-16

*

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:47*/

public staticString getCurrentTimeDay() {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd");

String time=format.format(newDate());returntime;

}/*** 獲取時間,格式為 201606161032053

*

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:34:09*/

public staticString getuniqukey() {

DateFormat format= new SimpleDateFormat("yyyyMMddHHmmsss");

String time=format.format(newDate());returntime;

}/*** 將 Date 轉換為 時間格式 格式為 yyyy-MM-dd HH:mm:ss

*

*@paramdate

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:50*/

public staticString convertTimeSceond(Date date) {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String time=format.format(date);returntime;

}/*** 將 Date 轉換為 時間格式 格式為 yyyy-MM-dd

*

*@paramdate

*@returnString

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:54*/

public staticString convertTimeDay(Date date) {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd");

String time=format.format(date);returntime;

}/*** 將 String格式的時間 轉換為 時間格式 格式為 Thu Jun 16 10:52:53 CST 2016

*

*@paramtime

*@returnDate

*@authorjingxue.chen

* @date 2016-6-16 上午10:33:57*/

public staticDate convertDateSceond(String time) {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date date=null;try{

date=format.parse(time);

}catch(ParseException e) {

e.printStackTrace();

}returndate;

}/*** 將 String格式的時間 轉換為 時間格式 格式為 Thu Jun 16 00:00:00 CST 2016

*

*@paramtime

*@returnDate

*@authorjingxue.chen

* @date 2016-6-16 上午10:34:01*/

public staticDate convertDateDay(String time) {

DateFormat format= new SimpleDateFormat("yyyy-MM-dd");

Date date=null;try{

date=format.parse(time);

}catch(ParseException e) {

e.printStackTrace();

}returndate;

}/*** 判斷 第一個時間是否大于第二個時間 false

*

*@paramdate1

*@paramdate2

*@returnboolean

*@authorjingxue.chen

* @date 2016-6-16 上午10:34:05*/

public static booleancompDate(String date1,String date2) {

SimpleDateFormat format= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");boolean time=false;try{

Date dates1=format.parse(date1);

Date dates2=format.parse(date2);if(dates1.getTime()>dates2.getTime()){

time=true;

}

}catch(ParseException e) {

e.printStackTrace();

}returntime;

}

}

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的java 当前时间格式_java 处理时间的各种方式——获取时间——时间格式化的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。