Obtain the calendar year list, log year list all years

Source: Internet
Author: User
Protected List getYears (Long userno, String end) throws Exception {List returnList = new ArrayList (); // obtain the year (obtain the year List based on the current employee ID, release schedule, and log earliest time) List cjsjSch = this. getBaseBiz (). getSchHasYear (userno, end); // the data stored in the cjsjSch set is Date-type List cjsjLog = this. getBaseBiz (). getLogHasYear (userno, end); // cyclically obtain the calendar year for (int I = 0; I <cjsjSch. size (); I ++) {Date sj = (Date) cjsjSch. get (I); // The Object returned by the get (int index) method in the cjsjSch set is of the Object type and must be forcibly converted to String sj_strString = DateUtils. dateToStr (sj); // convert Date to String returnList. add (sj_strString.substring (0, 4);} // obtain the log year in a loop (int j = 0; j <cjsjLog. size (); j ++) {Date sj = (Date) cjsjLog. get (j); String sj_strString = DateUtils. dateToStr (sj); returnList. add (sj_strString.substring (0, 4);} // remove returnList = remo (returnList) for duplicate years; // sort Collections in ascending order. sort (returnList); // sort Collections in descending order. reverse (returnList); return returnList ;}

Conversion between short-time format strings and short-time formats

/*** Convert the short-time format to the string yyyy-mm-dd ** @ Param datedate * @ Param K * @ return */public static string datetostr (Java. util. date datedate) {simpledateformat formatter = new simpledateformat ("yyyy-mm-dd"); string datestring = formatter. format (datedate); Return datestring ;} /*** convert a short-time string to a time string in yyyy-mm-dd *** @ Param strdate * @ return */public static date strtodate (string strdate) {If (strdate = NULL) {return NULL;} simpledateformat formatter = new simpledateformat ("yyyy-mm-dd"); parseposition Pos = new parseposition (0 ); date strtodate = formatter. parse (strdate, POS); Return strtodate ;} /*** convert short-time format strings to time yyyy *** @ Param strdate * @ return */public static date strtodateyyyy (string strdate) {If (strdate = NULL) {return NULL;} simpledateformat formatter = new simpledateformat ("YYYY"); parseposition Pos = new parseposition (0); Date strtodate = formatter. parse (strdate, POS); Return strtodate ;}

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.