Date calculation implemented in java and date calculation implemented in java

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.