前端传一个时间,在后台中比较时间大小的操作

public void getOperatingImcomeDataList(){
        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date state=DateUtil.getDateByString(beginTime,DateUtil.DATE_PATTERN_23);
        Date edate=DateUtil.getDateByString(endTime,DateUtil.DATE_PATTERN_15);
        String Sdate = format.format(state);
        String Edate = format.format(edate);
        try {
            if(state.getTime()<edate.getTime()){
                StringBuffer sb=new StringBuffer();
                sb.append("select CONVERT(CHAR(7),OPERATING_DATE,120) as time," +
                                   "COUNT(LINE_ID) as totalLine, " +
                                   "SUM(TOTAL_NUMBER)as totalAmount," +
                                   "SUM(COIN_NUMBER)as totalCoin, " +
                                   "SUM(CARD_NUMBER)as totalCard," +
                                   "SUM(STUDENT_CARD_NUMBER)as totalStu, " +
                                   "SUM(ELDERLY_CARD_NUMBER)as totalEld," +
                                   "SUM(MILITARY_CARD_NUMBER)as totalMilit, " +
                                   "SUM(DISABILITIES_CARD_NUMBER)as totalDisab " +
                  "from LN_BUS_OPERATING_INCOME  where ");
                sb.append("OPERATING_DATE>=‘"+Sdate+"‘ and  OPERATING_DATE<=‘"+Edate+"‘ ");
                sb.append(" GROUP BY CONVERT(CHAR(7),OPERATING_DATE,120)");
               System.out.println("==============="+sb.toString());
        List<Map<String, Object>>  list  = lnBusOperatingIncomeService.findListMapBySql(sb.toString());
        writeJson(list);
        }else{
            this.writeJson(obj.put("3", "查询结束时间不能早于开始时间!"));
            }
        } catch (Exception e){
            e.printStackTrace();
        }
    }
package com.inetsoft.hfgj.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.TimeZone;

/**
 * 日期处理类
 *
 * @author dyhu
 * @version 1.0
 * @since 2010-8-27
 */
public class DateUtil
{
    public static final int ONE_SECOND = 1000;
    public static final int ONE_MINUTE = 60 * ONE_SECOND;
    public static final int ONE_HOUR = 60 * ONE_MINUTE;
    public static final long ONE_DAY = 24 * ONE_HOUR;
    public static final long ONE_WEEK = 7 * ONE_DAY;
    /**
     * @see TimeZone#getRawOffset
     */
    @SuppressWarnings("unused")
    private static final int offSet;

    public static final String DATE_PATTERN_01 = "yyyy/MM/dd";
    public static final String DATE_PATTERN_02 = "yyyyMMddHHmmssSSS";
    public static final String DATE_PATTERN_03 = "yyyyMMddHHmmss";
    public static final String DATE_PATTERN_04 = "yyyy/MM/dd HH:mm:ss";
    public static final String DATE_PATTERN_05 = "HH:mm:ss";
    public static final String DATE_PATTERN_06 = "HH:mm";
    public static final String DATE_PATTERN_07 = "HHmm";
    public static final String DATE_PATTERN_08 = "yyyy/MM";
    public static final String DATE_PATTERN_09 = "yyyyMM";
    public static final String DATE_PATTERN_10 = "yyyy";
    public static final String DATE_PATTERN_11 = "MM";
    public static final String DATE_PATTERN_12 = "dd";
    public static final String DATE_PATTERN_13 = "MM/dd";
    public static final String DATE_PATTERN_14 = "yyyy/MM/dd HH:mm";
    public static final String DATE_PATTERN_15 = "yyyy-MM-dd";
    public static final String DATE_PATTERN_16 = "yyyyMMdd";
    public static final String DATE_PATTERN_17 = "yyyy-MM-dd HH:mm";
    public static final String DATE_PATTERN_18 = "yyyy-MM-dd HH:mm:ss";
    public static final String DATE_PATTERN_19 = "yyyy年MM月dd日";
    public static final String DATE_PATTERN_20 = "HHmmssS";
    public static final String DATE_PATTERN_21 = "yyyyMMddHH";
    public static final String DATE_PATTERN_22 = "yyyy.MM.dd HH.mm.ss";
    public static final String DATE_PATTERN_23 = "yyyy-MM";

    private static Set<String> datePatternSet;

    static
    {
        datePatternSet = new HashSet<String>();
        datePatternSet.add(DATE_PATTERN_01);
        datePatternSet.add(DATE_PATTERN_02);
        datePatternSet.add(DATE_PATTERN_03);
        datePatternSet.add(DATE_PATTERN_04);
        datePatternSet.add(DATE_PATTERN_05);
        datePatternSet.add(DATE_PATTERN_06);
        datePatternSet.add(DATE_PATTERN_07);
        datePatternSet.add(DATE_PATTERN_08);
        datePatternSet.add(DATE_PATTERN_09);
        datePatternSet.add(DATE_PATTERN_10);
        datePatternSet.add(DATE_PATTERN_11);
        datePatternSet.add(DATE_PATTERN_12);
        datePatternSet.add(DATE_PATTERN_13);
        datePatternSet.add(DATE_PATTERN_14);
        datePatternSet.add(DATE_PATTERN_15);
        datePatternSet.add(DATE_PATTERN_16);
        datePatternSet.add(DATE_PATTERN_17);
        datePatternSet.add(DATE_PATTERN_18);
        datePatternSet.add(DATE_PATTERN_19);
        datePatternSet.add(DATE_PATTERN_20);
        datePatternSet.add(DATE_PATTERN_21);
        datePatternSet.add(DATE_PATTERN_22);
        datePatternSet.add(DATE_PATTERN_23);
        TimeZone timeZone = TimeZone.getDefault();
        offSet = timeZone.getRawOffset();
    }

    /**
     * 根据日期取得日期的String
     * @param pDate
     * @param datePattern
     * @return
     */
    public static String getDateString(Date pDate, String datePattern)
    {
        if (StringUtil.isEmpty(datePattern) || !datePatternSet.contains(datePattern))
        {
            // throw new IllegalArgumentException("Date Pattern error!");
            return "";
        }

        if (pDate == null)
        {
            // throw new IllegalArgumentException("inputed Date error!");
            return "";
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);

        return dateFormat.format(pDate);
    }

    /**
     * String to date
     *
     * @author 7308905
     */
    public static Date getDateByString(String str, String datePattern)
    {
        if (StringUtil.isEmpty(datePattern) || !datePatternSet.contains(datePattern))
        {
            return null;
        }

        if (StringUtil.isEmpty(str))
        {
            return null;
        }

        SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern);

        try
        {
            return dateFormat.parse(str);
        }
        catch (ParseException pe)
        {
            pe.printStackTrace();
        }

        return null;
    }

    /**
     * 取得日期的星期(星期三)
     * @param date
     * @return
     */
    static public String getXinqi(Date date)
    {
        String youbi = "";

        if (date == null)
        {
            return youbi;
        }

        SimpleDateFormat formatter = new SimpleDateFormat("E");
        youbi = formatter.format(date);

        return youbi;
    }

    /**
     * 取得日期的星期,
     * 星期一:1
     * 星期二:2
     * 星期三:3
     * 星期四:4
     * 星期五:5
     * 星期六:6
     * 星期日:7
     * @param date
     * @return
     */
    public static int getXinqiInt(Date date)
    {
        int theWeek = 0;

        if (date == null)
        {
            return theWeek;
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        theWeek = calendar.get(Calendar.DAY_OF_WEEK);
        if (theWeek != 1)
        {
            theWeek = theWeek -1;
        }
        else
        {
            theWeek = 7;
        }
        return theWeek;
    }

    /**
     * 取得系统时间
     *
     * @return 系统时间
     */
    public static Date getSysDate()
    {
        return new Date(System.currentTimeMillis());
    }

    /**
     * 取得系统时间YYYYMMDD格式
     *
     * @return 系统时间
     */
    public static Date getSysDateYYYYMMDD()
    {
        Date today = getSysDate();
        String strToday = dt2Str(today);
        today = str2Dt(strToday);
        return today;
    }

    /**
     *
     * @return
     */
    public static Date getDateNoTime(Date dt)
    {
//        String strToday = dt2Str(dt);
//        Date newDt = str2Dt(strToday);
//        return newDt;
        if (dt == null) {
            return null;
        }
        Calendar cl = Calendar.getInstance();
        cl.setTimeInMillis(dt.getTime());
        cl.set(Calendar.HOUR_OF_DAY, 0);
        cl.set(Calendar.MINUTE, 0);
        cl.set(Calendar.SECOND, 0);
        cl.set(Calendar.MILLISECOND, 0);
        return cl.getTime();
    }

    /**
     * 取得yyyyMMddHHmmssSSS格式的日期字符串
     *
     * @param dt 日期
     * @return 日期字符串
     */
    public static String dateTime2Str(Date dt)
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        return sdf.format(dt);
    }

    /**
     * 取得yyyy/MM/dd格式的日期字符串
     *
     * @param dt 日期
     * @return 日期字符串(yyyy/MM/dd)
     */
    public static String dt2Str(Date dt)
    {
        if (dt != null)
        {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
            return sdf.format(dt);
        }
        else
        {
            return null;
        }
    }

    /**
     * 通过yyyy/MM/dd格式的日期字符串,取得日期
     *
     * @param ymd 日期字符串
     * @return 日期
     */
    public static Date str2Dt(String ymd)
    {
        if (ymd == null)
        {
            return null;
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        try
        {
            Date ret = sdf.parse(ymd);
            return ret;
        }
        catch (ParseException e)
        {
            return null;
        }
    }

    /**
     * 取得yyyyMMdd格式的日期字符串
     *
     * @param dt 日期
     * @return 日期字符串(yyyyMMdd)
     */
    public static String dt2Str8(Date dt)
    {
        if (dt != null)
        {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
            return sdf.format(dt);
        }
        else
        {
            return null;
        }
    }

    /**
     * 取得HH:mm格式的日期字符串
     *
     * @param dt 日期
     * @return 日期字符串(HH:mm)
     */
    public static String dt2HHmm(Date dt)
    {
        if (dt != null)
        {
            String date = dateTime2Str(dt);
            return date.substring(8, 10) + ":" + date.substring(10, 12);
        }
        else
        {
            return null;
        }

    }

    /**
     * (HHmm) to (HH:mm)
     */
    public static String dt2HHmm(String dt)
    {
        if (dt != null)
        {
            return dt.substring(0, 2) + ":" + dt.substring(2, 4);
        }
        else
        {
            return null;
        }

    }

    /**
     *
     */
    public static Date add(Date date, int field, int amount)
    {
        if (date == null)
        {
            return null;
        }

        Calendar calendar = GregorianCalendar.getInstance(Locale.CHINA);
        calendar.setTime(date);
        calendar.add(field, amount);

        return calendar.getTime();
    }

    /**
     * 加N个月
     */
    public static Date addMonths(Date date, int monthAmount)
    {
        return add(date, Calendar.MONTH, monthAmount);
    }

    /**
     * 加N天
     */
    public static Date addDays(Date date, int dayAmount)
    {
        return add(date, Calendar.DATE, dayAmount);
    }

    /**
     * 加N个小时
     */
    public static Date addHours24(Date date, int hourAmount)
    {
        return add(date, Calendar.HOUR_OF_DAY, hourAmount);
    }

    /**
     * 加N分钟
     */
    public static Date addMinutes(Date date, int minuteAmount)
    {
        return add(date, Calendar.MINUTE, minuteAmount);
    }

    /**
     * 加N秒
     */
    public static Date addSeconds(Date date, int secondAmount)
    {
        return add(date, Calendar.SECOND, secondAmount);
    }

    /**
     * 两个日期是否在一个月内
     * @param dateFrom 开始时间
     * @param dateTo 结束时间
     * @param monthAmount
     * @return
     */
    public static boolean isScopeOfMonth(Date dateFrom, Date dateTo, int monthAmount)
    {
        if (!dateTo.before(DateUtil.addMonths(dateFrom, monthAmount)))
        {
            return false;
        }
        return true;
    }

    /**
     * 获取时间(YYYY年MM月DD日 星期XX)
     *
     * @return
     */
    public static String getSysDateWeek()
    {
        int theYear = 0;
        int theMonth = 0;
        int theDay = 0;
        int theWeek = 0;
        String theWeekUpper = "";
        String thedate = "";

        Calendar calendar = Calendar.getInstance();

        theYear = calendar.get(Calendar.YEAR);
        theMonth = calendar.get(Calendar.MONTH) + 1;
        theDay = calendar.get(Calendar.DAY_OF_MONTH);
        theWeek = calendar.get(Calendar.DAY_OF_WEEK);

        switch (theWeek)
        {
            case 1:
                theWeekUpper = "日";
                break;
            case 2:
                theWeekUpper = "一";
                break;
            case 3:
                theWeekUpper = "二";
                break;
            case 4:
                theWeekUpper = "三";
                break;
            case 5:
                theWeekUpper = "四";
                break;
            case 6:
                theWeekUpper = "五";
                break;
            case 7:
                theWeekUpper = "六";
                break;
            default:
                break;
        }

        thedate = "" + theYear + "年" + theMonth + "月" + theDay + "日" + " 星期" + theWeekUpper;

        return thedate;
    }

    /**
     * 日期显示
     * @param b
     * @return
     */
    public static String getDateWeek(Date b)
    {
//        int theYear = 0;
        int theMonth = 0;
        int theDay = 0;
        int theWeek = 0;
        String theWeekUpper = "";
        String thedate = "";

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(b);

//        theYear = calendar.get(Calendar.YEAR);
        theMonth = calendar.get(Calendar.MONTH) + 1;
        String strMonth = StringUtil.addZero(String.valueOf(theMonth), 2);
        theDay = calendar.get(Calendar.DAY_OF_MONTH);
        String strDay = StringUtil.addZero(String.valueOf(theDay), 2);
        theWeek = calendar.get(Calendar.DAY_OF_WEEK);

        switch (theWeek)
        {
            case Calendar.SUNDAY:
                theWeekUpper = "日";
                break;
            case Calendar.MONDAY:
                theWeekUpper = "一";
                break;
            case Calendar.TUESDAY:
                theWeekUpper = "二";
                break;
            case Calendar.WEDNESDAY:
                theWeekUpper = "三";
                break;
            case Calendar.THURSDAY:
                theWeekUpper = "四";
                break;
            case Calendar.FRIDAY:
                theWeekUpper = "五";
                break;
            case Calendar.SATURDAY:
                theWeekUpper = "六";
                break;
            default:
                break;
        }

        thedate = strMonth + "月" + strDay + "日(周" + theWeekUpper+")";

        return thedate;
    }

    public static Date mondayOfWeek(Date date) {
        Calendar cl = Calendar.getInstance();
        cl.setTime(date);
        int dayOfWeek = cl.get(Calendar.DAY_OF_WEEK);
        dayOfWeek = dayOfWeek == 1 ? 6 : dayOfWeek - 2;
        cl.add(Calendar.DAY_OF_WEEK, -dayOfWeek);
        return cl.getTime();
    }

    public static Date sundayOfWeek(Date date) {
        Calendar cl = Calendar.getInstance();
        cl.setTime(date);
        int dayOfWeek = cl.get(Calendar.DAY_OF_WEEK);
        dayOfWeek = dayOfWeek == 1 ? 7 : dayOfWeek - 1;
        cl.add(Calendar.DAY_OF_WEEK, 7 - dayOfWeek);
        return cl.getTime();
    }

    /**
     * 计算时间差
     * @param fromDate 开始时间
     * @param toDate    结束时间
     * @return    相差几天
     */
    public static int datePoor(Date fromDate, Date toDate)
    {

        fromDate = DateUtil.getDateByString(DateUtil.getDateString(fromDate, DATE_PATTERN_18),DATE_PATTERN_15);
        toDate = DateUtil.getDateByString(DateUtil.getDateString(toDate, DATE_PATTERN_18),DATE_PATTERN_15);
        return (int)((toDate.getTime() - fromDate.getTime())/(1000*60*60*24));
    }

    /**
     * 计算时间差
     * @param fromDate 开始时间
     * @param toDate    结束时间
     * @return    相差多少分钟
     */
    public static int minPoor(Date fromDate, Date toDate)
    {

        return (int)((toDate.getTime() - fromDate.getTime())/(1000*60));
    }

    /**
     * 计算时间差
     * @param fromDate 开始时间
     * @param toDate    结束时间
     * @return    相差秒
     */
    public static int secondPoor(Date fromDate, Date toDate)
    {

        return (int)((toDate.getTime() - fromDate.getTime())/1000);
    }

    /**
     * 找到最近的周一
     *
     * @param k
     * @return
     */
    public static java.util.Date getNearMonday(java.util.Date k)
    {
        if (k != null)
        {
            return addDays(k, 0 - (getXinqiInt(k) - 1));
        }
        else
        {
            return null;
        }
    }

    /**
     * 找到最近的周六
     *
     * @param k
     * @return
     */
    public static java.util.Date getNearSaturday(java.util.Date k)
    {
        if (k != null)
        {
            return addDays(k, 0 - (getXinqiInt(k) + 1));
        }
        else
        {
            return null;
        }
    }

    /**
     * 如 1415948324 转成 2014-11-14 14:58:44
     * 将时间戳转成字符串类型
     * @author aicc
     * @param dateString
     * @return
     */
    public static String formatStringToDateString(String dateString){
        String str = "";
        try{
            if(dateString.contains(":")){//判断传过来的时间是否是时间类型的字符串,如果是则直接返回,否则转成时间类型字符串
                str = dateString;
            }else if(!"".equals(dateString)){
                dateString = dateString+"000";
                Long l = Long.valueOf(dateString);
                Date date = new Date(l);
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                str = sdf.format(date);
            }
        }catch(Exception e){

            e.printStackTrace();
        }
        return str;
    }
    /**
     * 获取本周第一天(这里第一天为礼拜一,而不是礼拜天)
     * @author aicc
     * @return
     */
    public static String getWeekFirstDateString(String datePattern){
        String str = "";
        str = DateUtil.getDateString(getNearMonday( new Date()),datePattern);
        return str;
    }
    /**
     * 获取上周第一天(这里第一天为礼拜一,而不是礼拜天)
     * @author aicc
     * @return
     */
    public static String getBeforeWeekFirstDateString(String datePattern){
        String str = "";
        str = DateUtil.getDateString(getNearMonday(addDays(new Date(), -7)), datePattern);
        return str;
    }
    /**
     * 获取上周最后一天(这里最后一天为礼拜天,而不是礼拜六)
     * @return
     */
    public static String getBeforeWeekLastDateString(String datePattern){
        String str = "";
        Date d = getNearMonday( new Date());
        str = DateUtil.getDateString(addDays(d, -1), datePattern);
        return str;
    }

    public static int compareDate(String date1, String date2, String pattern) {
        DateFormat df = new SimpleDateFormat(pattern);
        try {
           Date d1 = df.parse(date1);
           Date d2 = df.parse(date2);
           if (d1.getTime() > d2.getTime()) {
               return 1;
           } else if (d1.getTime() < d2.getTime()) {
               return -1;
           } else {
               return 0;
           }
        } catch (Exception exception) {
           exception.printStackTrace();
        }
        return -9999;
    }

    /**
     * 获取指定时间的最后一天
     * @param monthString
     * @param pattern
     * @return
     */
    public static String getLastDayOfMonth(String monthString,String pattern){
        int year = Integer.parseInt(monthString.split("-")[0]);
        int month = Integer.parseInt(monthString.split("-")[1]);

        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR,year);
        //设置月份
        cal.set(Calendar.MONTH, month-1);
        //获取某月最大天数
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        //设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, lastDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        String lastDayOfMonth = sdf.format(cal.getTime());
        return lastDayOfMonth;
    }

    /**
     * 比较两个日期的大小
     * @param dateStr1    格式为:yyyy-MM-dd
     * @param dateStr2    格式为:yyyy-MM-dd
     * @return    返回0:第一个大于第二个
     *             返回1:两个相等
     *             返回2:第一个小于第二个
     */
    public static String compareTwoDate(String dateStr1, String dateStr2, String formatStr) {
        if (dateStr1.length() == 8) {
            dateStr1 = transfer2LongDateDtPart(dateStr1);
        }
        if (dateStr2.length() == 8) {
            dateStr2 = transfer2LongDateDtPart(dateStr2);
        }

        SimpleDateFormat format = new SimpleDateFormat(formatStr);
         try{
             Date date1 = format.parse(dateStr1);
             Date date2 = format.parse(dateStr2);

             if (date1.getTime() > date2.getTime()) {
                 return "0";
             } else if (date1.getTime() == date2.getTime()) {
                 return "1";
             } else {
                 return "2";
             }
        }catch(Exception e){
            e.printStackTrace();
            return null;
        }
    }

    /**
     * 转换日期格式 yyyyMMdd => yyyy-MM-dd
     * @param dt yyyyMMdd
     * @return yyyy-MM-dd
     */
    public static String transfer2LongDateDtPart(String dt){
        if(dt==null||dt.length()!=8){
            return dt;
        }
        return dt.substring(0, 4).concat("-").concat(dt.substring(4, 6)).concat("-").concat(dt.substring(6));
    }

    /**
     * DATE to String,支持多种格式
     * @param date
     * @return
     */
    public static String dateToString(Date date,String format){
        if (date == null){
            return null;
        }
        return new SimpleDateFormat(format).format(date);
    }
    /**
     * @author hcc
     * 1.比较时间大小的
     * 2.(开始时间+addTime)和endTime的大小,
     * 3.如果(开始时间+addTime)小于endTime则返回true,否则返回false
     * 4.format格式必须是 HH:mm
     * 5.addTime必须是 以小时为单位
     * 6.beginTime和endTime的格式必须是   HH:mm
     * @param beginTime
     * @param endTime
     * @param format
     * @param addTime
     * @return
     */
    public static boolean compareTime(String beginTime,String endTime,String format,String addTime){
        boolean flag = false;

        String currentDate = getDateString(new Date(), DATE_PATTERN_15);

        beginTime = currentDate + " " + beginTime;
        endTime = currentDate + " " + endTime;

        Date bDate = getDateByString(beginTime, DATE_PATTERN_17);
        Date eDate = getDateByString(endTime, DATE_PATTERN_17);

        //相差多少分钟
        int min = minPoor(bDate,eDate);

        int addMin = (int) (Float.parseFloat(addTime)*60);
        if(addMin < min){//表示 (开始时间+addTime)小于endTime
            flag = true;
        }

        return flag;
    }

    /**
     *  获取几天的星期数组
     */
    public static String[] getNextDays(int i ){
        String days =  "星期日星期一星期二星期三星期四星期五星期六";
        String[] result = new String[i];
        Calendar instance = Calendar.getInstance();
        for(int k =0;k<i;k++){
            instance.add(Calendar.DATE,1);
            if(k==0){
                result[k] = "明天";
            }else{
                int num = instance.get(Calendar.DAY_OF_WEEK);
                result[k] = days.substring((num-1)*3,num*3);
            }

        }
        return result;
    }

    /**
     * 获取几天的日期数组
     */
    public static String[] getNextDates(int i){
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd");
        String[] result = new String[i];
        Calendar instance = Calendar.getInstance();
        for(int k =0;k<i;k++){
            instance.add(Calendar.DATE,1);
            result[k] = sdf.format(instance.getTime());
        }
        return result;
    }

    /**
     * 测试方法
     * @author aicc
     * @param args
     */
    public static void main(String[] args){
        compareTime("17:09","20:00","HH:mm","2");
    }

}
时间: 2024-11-05 15:33:32

前端传一个时间,在后台中比较时间大小的操作的相关文章

ajax data数据里面传一个json到后台的写法

$.ajax({                url:url+"/crm/contact",                type:'PUT',                contentType: "application/json",                timeout : "3000",                cache:false,                data: JSON.stringify({    

Extjs4 中date时间格式的问题

在Grid中显示时间,后台传过来的是date格式的数据(PHP date('Y-m-d', time()),一般在Ext model中定义数据的类型和格式: {name:'birth', type:'date'}, view层: { header: '生日', dataIndex: 'birth', editor:{ xtype: 'datefield', format : 'Y-m-d'}} 但这是个可编辑的grid row,通过搜索得知,必须自己定义renderer,试过: renderer

javaScript系列:js中获取时间new Date()详细介绍

var myDate = new Date();myDate.getYear(); //获取当前年份(2位)myDate.getFullYear(); //获取完整的年份(4位,1970-????)myDate.getMonth(); //获取当前月份(0-11,0代表1月)myDate.getDate(); //获取当前日(1-31)myDate.getDay(); //获取当前星期X(0-6,0代表星期天) 何问起 hovertree.commyDate.getTime(); //获取当前时

前端提供一个接口或者调用后台接口,这个接口具体指什么

ajax 我给你一个例子 (function () { var timing = null; console.log($(".name").length) timing=setInterval(function () { $.ajax( { type: "post", url: "http://t1.loocha.cn:9880/link/anchor/finalcompetitor?activityId=40987", data: {}, da

asp.net MVC 框架中控制器里使用Newtonsoft.Json对前端传过来的字符串进行解析

下面我用一个实例来和大家分享一下我的经验,asp.net MVC 框架中控制器里使用Newtonsoft.Json对前端传过来的字符串进行解析. using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Web.Mvc; namespace MyWebApp.Controllers { public class TestController : Controller { public A

关于前端传参数,后台接收的问题

1.通过ajax,示例: 传给后台的数据通过json封装起来,再用ajax将json传到后台,ajax是用到Jquery的ajax,在jsp先加入Jquery的引用 <script type="text/javascript" src="js/jquery-1.9.1.min.js"></script> js传值的方法如下 function testAjax() { var users=[{ name:'张三', age:'21', birt

iOS开发中如何将后台返回的时间转换为常见字串

在iOS开发中,经常需要从后台数据中获取时间,但是此时后台返回的时间格式经常是一串类似"123456789"的数字,此数字是1970年开始截至到现在的秒数,此时我们需要将其转换为可以用的格式. 模型中我定义了c_time属性,通过重写c_time的get方法中进行格式的转换. - (NSString *)c_time{ // 1.创建时间格式化类 NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; // 2.设置时间

ASP.NET上传一个文件夹

之前仿造uploadify写了一个HTML5版的文件上传插件,没看过的朋友可以点此先看一下~得到了不少朋友的好评,我自己也用在了项目中,不论是用户头像上传,还是各种媒体文件的上传,以及各种个性的业务需求,都能得到满足.小小开心了一把. 但无论插件再怎么灵活,也难以应付所有的需求,比如,你要上传一个2G的文件.以现在我们的网速,恐怕再快也得传半小时.要命的是,如果你在上传到90%的时候不小心关掉了浏览器,或者是手一抖摁了F5,完了,一切还得从头再来.这种用户体验简直太糟糕了.所以,断点续传就十分有

前端实习一个月的收获与思考

今年5月开始前端之旅,学习近4个月之后,于9月底,参与了一个商城厂家后台的前端页面的开发,所做的内容并不多,但是在这段时间的收获却不少.接下来将详细谈谈这些收获. 1)参与项目之前应该做什么 在实习刚开始的时候,主要是从git上clone代码,然后自己在前辈的指导下查看代码结构,理解整个流程.当时花的时间不长,基本也把代码看的差不多了.这个是很重要的,你需要对整个前端的架构有一个大致的了解. 2)写第一行代码前应该做什么 仔细看产品原型,查看接口文档.这是非常重要的,特别是原型,需要仔细的查看原