獲取具體日期天數和月份的工具類

2021-08-29 15:49:22 字數 738 閱讀 8713

前幾天做新版本的時候根據專案的需求做了幾個獲取日期的方法,網上也有很多,各種方法都有,但最終想要找到符合自己專案的還是很少很少。下面就是我自己用到的幾個方法,比較簡單,**寫的有問題的還請大家多多指正。o(∩_∩)o~

public

static string getcurrentmonthfirstday2str

(string date) throws parseexception

public

static date getcurrentmonthfirstdays2date

(string date) throws parseexception

public

static string getcurrentmonthlastday2str

(string date) throws parseexception

public

static date getcurrentmonthlastday2date

(string date) throws parseexception

public

static string getlastyearandmonth2str

() throws parseexception

else

}

Oracle獲取日期和月份

這個要用到add months 函式 引數 負數 代表 往前 正數 代表 往後。1 oracle獲得上個月的月份 select to char add months trunc sysdate 1 yyyymm from dual 2 oracle獲得下個月的月份 select to char ad...

JAVA獲取指定月份的天數

calendar ymcalendar calendar.getinstance date ymdate new date ymdate.setyear integer.parseint commonutils.getyear kokandayform.getkokanym ymdate.setmo...

獲取兩個日期之間的月份數與天數

返回乙個二維陣列,單位分別是月和日,代表兩個date之差。本方法忽略小時和分鐘。例 1,2012年6月1日到2012年6月3日,返回值是 0,2 2天 2,2012年6月15日到2012年8月4日,返回值是 1,20 1個月零20天 3,2011年11月3日到2013年1月14日,返回值是 14,1...