Java gets tomorrow, the current week of Friday, and the last day of the current month based on the current time

Source: Internet
Author: User

PrivateDate Getdatebytype (date date, Integer type) {Calendar Calendar=calendar.getinstance ();        Calendar.settime (date); Switch(type) { Case1:/*daily newspaper*/            //Tomorrow's dateCalendar.add (Calendar.date, 1);  Break;  Case2:/*Weekly*/            //get the current date is the day of the week one            intDayWeek =Calendar.get (Calendar.day_of_week); if(1 = =DayWeek) {Calendar.add (Calendar.day_of_month,-1); }            //set one the first day of the week, according to the Chinese habit one weeks the first day is MondayCalendar.setfirstdayofweek (Calendar.monday); //get the current date is the day of the week one            intDay =Calendar.get (Calendar.day_of_week); intFirst =Calendar.getfirstdayofweek (); //calculate dates for FridayCalendar.add (Calendar.day_of_week, First-day + 4);  Break;  Case3:/*Monthly Report*/            //get the maximum number of days of the month            intDays =Calendar.getactualmaximum (Calendar.day_of_month); //set to create a new date, this date is the last day of this monthCalendar.set (Calendar.date, days);  Break; default:             Break; }        returnCalendar.gettime (); }

Java gets tomorrow, the current week of Friday, and the last day of the current month based on the current time

Related Article

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.