Date calculation implemented in java and date calculation implemented in java
The date calculation here is relatively biased and rarely used (for example, obtaining the Monday or Sunday of the week where today is the week of the month ...), these methods are left over from previous projects. Now let's sort them out and share them with you.
The tool class mainly includes the following methods:Public static Date getFirstMondayOfMonth (String dateString, String dateFormat) throws Exception
Obtain the first Monday of the specified month. For example, the first Monday of 2014-Is December.
Public static int figureWeekIndexOfMonth (String dateString, String dateFormat) throws ExceptionCalculate the week number of the month. For example, if the first week of December is from 1 to 7, 2014-5 5 is the first week of, and 2014-12-12 is the second week.
Public static String getMondyOfToday (String format)
Returns a time string for Monday of the week. For example, if today is, the returned result is: (today is exactly Monday of this week)
Public static Date getSundayOfToday ()
Obtain the Sunday of the week where today is located. For example, if today is, 2014-12-14 is returned.
The detailed code of the tool class is as follows:
To test: