Java common query processing by start date and end date

Source: Internet
Author: User
Tags dateformat

Java common query processing by start date and end date


Package Com.crm.mess.util;import Java.text.dateformat;import Java.text.parseexception;import Java.text.simpledateformat;import Java.util.date;public class Dateutil {//@Testpublic static string sedate (string Start, String end) throws parseexception {dateformat format = new SimpleDateFormat ("Yyyy/mm/dd HH:mm:ss");D ateformat form Atstr = new SimpleDateFormat ("YYYY/MM/DD"); int daymis = + * * 24;////createtime=2015/01/16&endtime=2015/01 /16 23:59:59//If the date is empty query all if (start = = NULL | | ". Equals (Start)) && (end = = NULL | |" ". Equals (end)) {return "";} If the start date has an end date, then the query starts on the day of the time if (start! = NULL &&! "". Equals (start)) && (end = = NULL | | "". Equals (end)) {Long Endlong = Formatstr.parse (start). GetTime () + dayMis-1; String endstr = Format.format (new Date (Endlong)); System.out.println (ENDSTR); return "Createtime=" + start + "&endtime=" + endstr;} If the end date has a start date, then the query ends on the day of the time if (start = = NULL | | ". Equals (start) && (end! = NULL &&!"). EQuals (end)) {Long Endlong = Formatstr.parse (end). GetTime () + dayMis-1; String endstr = Format.format (new Date (Endlong)); System.out.println (ENDSTR); return "createtime=" + End + "&endtime=" + endstr;} Normal Date Query if (start! = NULL &&! "). Equals (start) && end! = null&&! "". Equals (end) {Long Endlong = Formatstr.parse (end). GetTime () + dayMis-1; String endstr = Format.format (new Date (Endlong)); System.out.println (ENDSTR); return "Createtime=" + start + "&endtime=" + endstr;} Return "Createtime=" + start + "&endtime=" + End;} public static void Main (string[] args) throws ParseException {sedate ("", "");}}


Java common query processing by start date and end date

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.