時間格式轉換工具類

2021-08-15 17:17:31 字數 975 閱讀 6043

時間日期工具類有很多,本文主要說的是將當前日期轉換為當前日期的開始時間,即當前日期的0點0分0秒以及當前日期的結束時間即23點59分59秒

/** 

* 得到當前日期字串開始時間格式(yyyy-mm-dd 00:00:00)

*/public static date getstarttime(string startime) catch (parseexception e)  

calendar todaystarttime=null;

todaystarttime = calendar.getinstance();

todaystarttime.settime(date);

todaystarttime.set(calendar.hour_of_day, 0);

todaystarttime.set(calendar.minute, 0);

todaystarttime.set(calendar.second, 0);

return todaystarttime.gettime();

}/**

* 得到當前日期字串結束時間格式(yyyy-mm-dd 23:59:59)

*/public static date getendtime(string endtime) catch (parseexception e)  

calendar todayendtime=null;

todayendtime = calendar.getinstance();

todayendtime.settime(date);

todayendtime.set(calendar.hour_of_day, 23);

todayendtime.set(calendar.minute, 59);

todayendtime.set(calendar.second, 59);

return todayendtime.gettime();

}

Android 時間轉換工具類

在做聊天頁面的時候,難免遇到要把乙個時間戳轉換為乙個好看的格式,每次都動手寫也太累了,在這裡給大家分享一下我的工具類吧 其中time year time month等 在文字最後貼出來給大家哦。時間轉換工具 public class timeutil 時間轉化為顯示字串 param timestam...

日期轉換工具類

都是一些比較常用的日期工具類 public final class dateutils 取得ap系統時間。return ap系統時間 public static date getsystemdate 取得ap系統時間,不包括時分秒。return ap系統時間 public static date g...

型別轉換工具類

做專案的時候自己封裝的工具類,方便查詢,放到這裡 public class convertutil inttostring int轉string author lelonta param i return public static string inttostr int i dubtobigdec...