Date comparison of recent processing of renewals

Source: Internet
Author: User

You should not waste too much time in JS. JS introduced into the version of the different also caused some problems. After the background judgment, the processing results will be passed on to the foreground processing.

Java processing gets a time to determine whether the current time is one year before the time, and six months later:

1  Packagetest;2 3 Importjava.text.ParseException;4 5  Public classTestDate {6 7      Public Static voidMain (string[] args)throwsParseException {8         //date a year ago9Java.text.SimpleDateFormat format =NewJava.text.SimpleDateFormat ("Yyyy-mm-dd"); TenJava.util.Date tmdatebegin= format.parse ("2016-8-31");  One         LongBeforetime= (Tmdatebegin.gettime ()/1000) -60*60*24*365;  ATmdatebegin.settime (beforetime*1000);  -String beforedate=Format.format (Tmdatebegin);  -System.out.println ("A year ago:" +beforedate); the         //six months after the date -Java.util.Date tmdateend= format.parse ("2016-8-31");  -         LongAftertime= (Tmdateend.gettime ()/1000) +60*60*12*365;  -Tmdateend.settime (aftertime*1000);  +String afterdate=Format.format (tmdateend);  -System.out.println ("Six months later:" +afterdate);  +         //Get Current date AJava.util.Date todaydate=Newjava.util.Date (); atJava.util.Date dateafterdate = Format.parse (afterdate);//Convert to date type -Java.util.Date datebeforedate = Format.parse (beforedate);//Convert to date type -         if((Todaydate.before (dateafterdate)) &&(Todaydate.after (datebeforedate))) { -System.out.println ("ok! Can be renewed "); -}Else{ -System.out.println ("Not ok! Cannot be renewed "); in         } -     } to  +}

Date comparison of recent processing of renewals

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.