java 计算天月季度年的起始结束时间戳(直接运行即可)

import org.frame.util.DateTools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by zhangyang on 2016/7/19.
 */
public class MyDateUtil {

    public static final String day = "day";
    public static final String week = "week";
    public static final String month = "month";
    public static final String quarter = "quarter";
    public static final String year = "year";

    private static SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd");
    private static SimpleDateFormat longHourSdf = new SimpleDateFormat("yyyy-MM-dd HH");
    private static SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    //	日/周/月/季度/年
//	day/week/month/quarter/year
//	日:2016-07-15
//	周:2016,20   2016年第20周
//	月:2016-06
//	季度:2016,1  2016年第1季度
//	年:2016

//    public static void main(String[] args) {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        long[] long1 = getBeginEndTimestamp("2016-07-15",day);
//        long[] long2 = getBeginEndTimestamp("2016-20",week);
//        long[] long3 = getBeginEndTimestamp("2016-06",month);
//        long[] long4 = getBeginEndTimestamp("2016-2",quarter);
//        long[] long5 = getBeginEndTimestamp("2016",year);
//
//        System.out.println(sdf.format(new Date(long1[0]))+ "   end : " + sdf.format(new Date(long1[1])));
//        System.out.println(sdf.format(new Date(long2[0]))+ "   end : " + sdf.format(new Date(long2[1])));
//        System.out.println(sdf.format(new Date(long3[0]))+ "   end : " + sdf.format(new Date(long3[1])));
//        System.out.println(sdf.format(new Date(long4[0]))+ "   end : " + sdf.format(new Date(long4[1])));
//        System.out.println(sdf.format(new Date(long5[0]))+ "   end : " + sdf.format(new Date(long5[1])));
//    }
}

import org.frame.util.DateTools;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * Created by zhangyang on 2016/7/19.
 */
public class MyDateUtil {

    public static final String day = "day";
    public static final String week = "week";
    public static final String month = "month";
    public static final String quarter = "quarter";
    public static final String year = "year";

    private static SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd");
    private static SimpleDateFormat longHourSdf = new SimpleDateFormat("yyyy-MM-dd HH");
    private static SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static long[] getBeginEndTimestamp(String input, String timeType) {
        long[] beginEndTime = new long[2];
        Calendar cal = Calendar.getInstance();
        switch (timeType) {
            case day:
                Date dateDay = DateTools.toDate(DateTools.yyyy_MM_dd, input);
                cal.setTime(dateDay);
                cal.add(Calendar.DAY_OF_YEAR, +1);
                beginEndTime[0] = dateDay.getTime();
                beginEndTime[1] = cal.getTime().getTime() - 1;
                return beginEndTime;
            case week:
                String[] yearAndWeek = input.split("-");
                int yearStr = Integer.parseInt(yearAndWeek[0]);
                int weekStr = Integer.parseInt(yearAndWeek[1]);

                beginEndTime[0] = getFirstDayOfWeek(yearStr, weekStr).getTime();
                beginEndTime[1] = getLastDayOfWeek(yearStr, weekStr).getTime();
                return beginEndTime;
            case month:
                Date dateMonth = DateTools.toDate("yyyy-MM", input);
                cal.setTime(dateMonth);
                cal.add(Calendar.MONTH, +1);
                beginEndTime[0] = dateMonth.getTime();
                beginEndTime[1] = cal.getTime().getTime() - 1;
                return beginEndTime;
            case quarter:
                String[] yearAndQuarter = input.split("-");
                int yearNum = Integer.parseInt(yearAndQuarter[0]);
                int quarterNum = Integer.parseInt(yearAndQuarter[1]);

                Date dateQuarter = DateTools.toDate("yyyy", yearNum);

                beginEndTime[0] = getCurrentQuarterStartTime(dateQuarter, quarterNum).getTime();
                beginEndTime[1] = getCurrentQuarterEndTime(dateQuarter, quarterNum).getTime();
                return beginEndTime;
            case year:
                Date dateYear = DateTools.toDate("yyyy", input);
                cal.setTime(dateYear);
                cal.add(Calendar.YEAR, +1);
                beginEndTime[0] = dateYear.getTime();
                beginEndTime[1] = cal.getTime().getTime() - 1;
                return beginEndTime;
            default:
                return beginEndTime;
        }
    }

    // 获取某年的第几周的开始日期
    public static Date getFirstDayOfWeek(int year, int week) {
        Calendar c = new GregorianCalendar();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, Calendar.JANUARY);
        c.set(Calendar.DATE, 1);

        Calendar cal = (GregorianCalendar) c.clone();
        cal.add(Calendar.DATE, week * 7);

        return getFirstDayOfWeek(cal.getTime());
    }

    // 获取当前时间所在周的开始日期
    public static Date getFirstDayOfWeek(Date date) {
        Calendar c = new GregorianCalendar();
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); // Monday
        try {
            return longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return new Date();
    }

    // 获取某年的第几周的结束日期
    public static Date getLastDayOfWeek(int year, int week) {
        Calendar c = new GregorianCalendar();
        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, Calendar.JANUARY);
        c.set(Calendar.DATE, 1);

        Calendar cal = (GregorianCalendar) c.clone();
        cal.add(Calendar.DATE, week * 7);

        return getLastDayOfWeek(cal.getTime());
    }

    // 获取当前时间所在周的结束日期
    public static Date getLastDayOfWeek(Date date) {
        Calendar c = new GregorianCalendar();
        c.setFirstDayOfWeek(Calendar.MONDAY);
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); // Sunday
        try {
            return longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return new Date();
    }

    public static Date getCurrentQuarterStartTime(Date date,int quarter) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);

        Date now = null;
        try {
            if (quarter == 1)
                c.set(Calendar.MONTH, 0);
            else if (quarter == 2)
                c.set(Calendar.MONTH, 3);
            else if (quarter == 3)
                c.set(Calendar.MONTH, 6);
            else if (quarter == 4)
                c.set(Calendar.MONTH, 9);
            c.set(Calendar.DATE, 1);
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 当前季度的结束时间,即2012-03-31 23:59:59
     *
     * @return
     */
    public static  Date getCurrentQuarterEndTime(Date date,int quarter) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);

        Date now = null;
        try {
            if (quarter == 1) {
                c.set(Calendar.MONTH, 2);
                c.set(Calendar.DATE, 31);
            } else if (quarter == 2) {
                c.set(Calendar.MONTH, 5);
                c.set(Calendar.DATE, 30);
            } else if (quarter == 3) {
                c.set(Calendar.MONTH,8);
                c.set(Calendar.DATE, 30);
            } else if (quarter == 4) {
                c.set(Calendar.MONTH, 11);
                c.set(Calendar.DATE, 31);
            }
            now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return now;
    }

    /**
     * 获取某天0:00的时间戳
     * @param amount 偏移几天 0当天 -1昨天 1明天
     * @return
     */
    public static long getDayZeroTime(int amount) {
        long now = System.currentTimeMillis();
        Date d1 = new Date(now);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String d1Str = sdf.format(d1);
        Date d1Zero = null;
        try {
            d1Zero = sdf.parse(d1Str);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(d1Zero);
        calendar.add(Calendar.DAY_OF_MONTH, amount);
        Date date = calendar.getTime();
        return date.getTime();
    }


   
  
 
  

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import org.frame.util.StringTools;

public class DateTools {
    public static String yyyy_MM_dd = "yyyy-MM-dd";
    public static String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
    public static String HH_mm_ss = "HH:mm:ss";
    public static String yyyyMMdd = "yyyyMMdd";
    public static String yyyyMMddHHmmss = "yyyyMMddHHmmss";
    public static String MM_dd_yyyy = "MM-dd-yyyy";
    public static String MM_dd_yyyy_HH_mm_ss = "MM-dd-yyyy HH:mm:ss";
    private static final String DEFAULT_FORMAT = "yyyy_MM_dd_HH_mm_ss";

    public DateTools() {
    }

    public static Date createDate(String timeStr) {
        return !StringTools.isNullToBoolean(timeStr) && timeStr.length() == 14?toDate(yyyyMMddHHmmss, timeStr):new Date();
    }

    public static boolean checkTime(int bigenh, int bigenm, int endh, int endm) {
        boolean result = false;
        int h = getCurrentHour().intValue();
        int m = getCurrentMINUTE().intValue();
        if(bigenh != endh && (h > bigenh && h < endh || h == bigenh && m >= bigenm || h == endh && m <= endm) || bigenh == endh && m >= bigenm && m <= endm) {
            result = true;
        }

        return result;
    }

    public static boolean checkDay(int m, int d) {
        boolean result = false;
        if(m == getMonth().intValue() && d == getDay().intValue()) {
            result = true;
        }

        return result;
    }

    public static Integer getDay(Date date) {
        return Integer.valueOf(toCalendar(date).get(5));
    }

    public static Integer getDay() {
        return Integer.valueOf(getCalendar().get(5));
    }

    public static long intervalDays(Date endDate, Date startDate) {
        return intervalSesonds(endDate, startDate) / 86400L;
    }

    public static long intervalSesonds(Date endDate, Date startDate) {
        long time = 0L;
        time = endDate.getTime() - startDate.getTime();
        return time /= 1000L;
    }

    public static int getTheMonths(Date date) {
        Calendar c = toCalendar(date);
        int year = c.get(1);
        int month = c.get(2) + 1;
        return year * 12 + month;
    }

    public static Integer getMonth(Date date) {
        return Integer.valueOf(toCalendar(date).get(2) + 1);
    }

    public static Integer getMonth() {
        return Integer.valueOf(getCalendar().get(2) + 1);
    }

    public static Integer getCurrentDayOfWeek() {
        return Integer.valueOf(getCalendar().get(7));
    }

    public static Integer getCurrentMINUTE() {
        return Integer.valueOf(getCalendar().get(12));
    }

    public static Integer getCurrentHour() {
        return Integer.valueOf(getCalendar().get(11));
    }

    public static Integer getCurrentWeek() {
        return Integer.valueOf(getCalendar().get(3));
    }

    public static Integer getCurrentDayOfMonth() {
        return Integer.valueOf(getCalendar().get(5));
    }

    public static String getCurrentDate() {
        return format(yyyy_MM_dd, getDate());
    }

    public static long getWeehoursTime() {
        return toLong(HH_mm_ss, "00:00:00");
    }

    public static Integer getCurrentDay() {
        return Integer.valueOf(getCalendar().get(6));
    }

    public static Locale getLocale() {
        return Locale.getDefault();
    }

    public static TimeZone getTimeZone() {
        return TimeZone.getDefault();
    }

    public static Date getDate() {
        return getCalendar().getTime();
    }

    public static Calendar getCalendar() {
        return Calendar.getInstance(getTimeZone(), getLocale());
    }

    private static String getFormat() {
        return "yyyy_MM_dd_HH_mm_ss";
    }

    public static String format(Object obj) {
        return format(getFormat(), obj);
    }

    public static String format(String format, Object obj) {
        return format(format, obj, getLocale());
    }

    private static String format(String format, Object obj, Locale locale) {
        return format(format, obj, locale, getTimeZone());
    }

    private static String format(String format, Object obj, Locale locale, TimeZone timezone) {
        Date date = toDate(obj);
        DateFormat df = getDateFormat(format, locale, timezone);
        return date != null && df != null?df.format(date):null;
    }

    private static DateFormat getDateFormat(String format, Locale locale, TimeZone timezone) {
        if(format == null) {
            return null;
        } else {
            Object df = null;
            String style;
            int style1;
            if(format.endsWith("_date")) {
                style = format.substring(0, format.length() - 5);
                style1 = getStyleAsInt(style);
                df = getDateFormat(style1, -1, locale, timezone);
            } else if(format.endsWith("_time")) {
                style = format.substring(0, format.length() - 5);
                style1 = getStyleAsInt(style);
                df = getDateFormat(-1, style1, locale, timezone);
            } else {
                int style2 = getStyleAsInt(format);
                if(style2 < 0) {
                    df = new SimpleDateFormat(format, locale);
                    ((DateFormat)df).setTimeZone(timezone);
                } else {
                    df = getDateFormat(style2, style2, locale, timezone);
                }
            }

            return (DateFormat)df;
        }
    }

    private static DateFormat getDateFormat(int dateStyle, int timeStyle, Locale locale, TimeZone timezone) {
        try {
            DateFormat suppressed;
            if(dateStyle < 0 && timeStyle < 0) {
                suppressed = DateFormat.getInstance();
            } else if(timeStyle < 0) {
                suppressed = DateFormat.getDateInstance(dateStyle, locale);
            } else if(dateStyle < 0) {
                suppressed = DateFormat.getTimeInstance(timeStyle, locale);
            } else {
                suppressed = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale);
            }

            suppressed.setTimeZone(timezone);
            return suppressed;
        } catch (Exception var5) {
            return null;
        }
    }

    private static int getStyleAsInt(String style) {
        return style != null && style.length() >= 4 && style.length() <= 7?(style.equalsIgnoreCase("full")?0:(style.equalsIgnoreCase("long")?1:(style.equalsIgnoreCase("medium")?2:(style.equalsIgnoreCase("short")?3:(style.equalsIgnoreCase("default")?2:-1))))):-1;
    }

    private static Date toDate(Object obj) {
        return toDate(getFormat(), obj, getLocale(), getTimeZone());
    }

    public static Date toDate(String format, Object obj) {
        return toDate(format, obj, getLocale(), getTimeZone());
    }

    public static Date toDate(String format, Object obj, Locale locale) {
        return toDate(format, obj, locale, getTimeZone());
    }

    public static Date toDate(String format, Object obj, Locale locale, TimeZone timezone) {
        if(obj == null) {
            return null;
        } else if(obj instanceof Date) {
            return (Date)obj;
        } else if(obj instanceof Calendar) {
            return ((Calendar)obj).getTime();
        } else if(obj instanceof Long) {
            Date e1 = new Date();
            e1.setTime(((Long)obj).longValue());
            return e1;
        } else if(obj instanceof String) {
            try {
                return (new SimpleDateFormat(format)).parse((String)obj);
            } catch (Exception var5) {
                return null;
            }
        } else {
            try {
                DateFormat e = getDateFormat(format, locale, timezone);
                return e.parse(String.valueOf(obj));
            } catch (Exception var6) {
                return null;
            }
        }
    }

    public static Calendar toCalendar(Object obj) {
        return toCalendar(obj, getLocale());
    }

    private static Calendar toCalendar(Object obj, Locale locale) {
        if(obj == null) {
            return null;
        } else if(obj instanceof Calendar) {
            return (Calendar)obj;
        } else {
            Date date = toDate(obj);
            if(date == null) {
                return null;
            } else {
                Calendar cal = Calendar.getInstance(locale);
                cal.setTime(date);
                cal.getTime();
                return cal;
            }
        }
    }

    public static long toLong(Object obj) {
        Date date = toDate(obj);
        return date.getTime();
    }

    public static long toLong(String format, Object obj) {
        Date date = toDate(format, obj);
        return date.getTime();
    }

    /** @deprecated */
    public static Date getNextDate(Date date) {
        return new Date(date.getTime() + 86400000L);
    }

    /** @deprecated */
    public static Date getNextMonth(Date date) {
        Calendar cal = toCalendar(date);
        String tempDate = cal.get(1) + "-" + (cal.get(2) + 2) + "-01";

        try {
            return (new SimpleDateFormat(yyyy_MM_dd)).parse(tempDate);
        } catch (ParseException var4) {
            return null;
        }
    }

    /** @deprecated */
    public static Date getNextYear(Date date) {
        Calendar cal = toCalendar(date);
        String tempDate = cal.get(1) + 2 + "-" + "-01" + "-01";

        try {
            return (new SimpleDateFormat(yyyy_MM_dd)).parse(tempDate);
        } catch (ParseException var4) {
            return null;
        }
    }

    public static int checktime(String startTime, String endTime) {
        Date now = new Date();
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        Calendar cal3 = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        cal1.setTime(now);

        try {
            cal2.setTime(sdf.parse(startTime));
            cal3.setTime(sdf.parse(endTime));
        } catch (ParseException var8) {
            var8.printStackTrace();
        }

        return cal2.before(cal1) && cal3.after(cal1)?1:(cal2.after(cal1)?2:(cal3.before(cal1)?3:0));
    }

    /** @deprecated */
    public static long getLastTimeForDay(long currentTime, int count) {
        for(int i = 1; i <= count; ++i) {
            currentTime -= 86400000L;
        }

        return currentTime;
    }

    /** @deprecated */
    public String toString() {
        return format(getFormat(), getDate());
    }

    public static String formatDate(long ms) {
        short ss = 1000;
        int mi = ss * 60;
        int hh = mi * 60;
        int dd = hh * 24;
        long day = ms / (long)dd;
        long hour = (ms - day * (long)dd) / (long)hh;
        long minute = (ms - day * (long)dd - hour * (long)hh) / (long)mi;
        long second = (ms - day * (long)dd - hour * (long)hh - minute * (long)mi) / (long)ss;
        StringBuilder sb = new StringBuilder();
        if(day > 0L) {
            sb.append(day).append("天");
        }

        if(hour > 0L) {
            sb.append(hour).append("小时");
        }

        if(minute > 0L) {
            sb.append(minute).append("分");
        }

        if(second > 0L) {
            sb.append(second).append("秒");
        }

        return sb.toString();
    }
}

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.frame.util.NumberTools;
import org.springframework.web.util.HtmlUtils;

public class StringTools extends StringUtils {
    public StringTools() {
    }

    public static void createdNumber(String num) {
        int len = num.length();
        char[] numStr = num.toCharArray();
        int[] _num = new int[numStr.length];

        for(int i = 0; i < numStr.length; ++i) {
            _num[i] = NumberTools.toInteger(Character.valueOf(numStr[i])).intValue();
            System.out.println(_num[i]);
        }

    }

    public static String booleanToIntStr(boolean flag) {
        return flag?"1":"0";
    }

    public static String trimIncSBCcase(String str) {
        String reStr = trim(str);
        if(reStr == null) {
            return null;
        } else {
            char[] value = reStr.toCharArray();
            int len = value.length;

            int st;
            for(st = 0; st < len && value[st] == 12288; ++st) {
                ;
            }

            while(st < len && value[len - 1] == 12288) {
                --len;
            }

            return st <= 0 && len >= value.length?reStr:reStr.substring(st, len);
        }
    }

    public static String checkNull(Object str) {
        return str != null && !str.toString().equals("") && !str.toString().equals("0")?str.toString():"0";
    }

    public static String tripRightStr(String rawStr) {
        return rawStr.substring(0, rawStr.length() - 1);
    }

    public static boolean isRequestParameter(Object obj) {
        boolean isExist = false;
        if(obj != null && !"".equals(obj)) {
            isExist = true;
        }

        return isExist;
    }

    public static String isRemove(String str, String remove, String removeChar) {
        String[] removeStr = split(remove, removeChar);

        for(int temp = 0; temp < removeStr.length; ++temp) {
            str = remove(str, removeStr[temp]);
        }

        String[] var7 = split(str, removeChar);
        StringBuilder builder = new StringBuilder();

        for(int data = 0; data < var7.length; ++data) {
            builder.append(var7[data]);
            builder.append(removeChar);
        }

        String var8 = builder.toString();
        return !"".equals(var8)?builder.substring(0, builder.length() - 1):null;
    }

    public static String isNullToString(String str) {
        return str != null && !str.equals("")?str:"0";
    }

    public static boolean isNullToBoolean(String str) {
        boolean result = true;
        if(isEmpty(str)) {
            return result;
        } else if(isEmpty(str.trim())) {
            return result;
        } else {
            result = false;
            return result;
        }
    }

    public static String utftoIso(String str) {
        String strIso = null;

        try {
            strIso = new String(str.getBytes("utf-8"), "iso-8859-1");
        } catch (UnsupportedEncodingException var3) {
            var3.printStackTrace();
        }

        return strIso;
    }

    public static String isoToUtf(String str) {
        String strUtf = null;

        try {
            strUtf = new String(str.getBytes("iso-8859-1"), "utf-8");
        } catch (UnsupportedEncodingException var3) {
            var3.printStackTrace();
        }

        return strUtf;
    }

    public static boolean lastWith(String str, String searchStr) {
        boolean result = false;
        if(isNullToBoolean(str)) {
            return result;
        } else if(isNullToBoolean(searchStr)) {
            return true;
        } else {
            int index = lastIndexOf(str, searchStr);
            if(index < 0) {
                return result;
            } else {
                if(str.length() == searchStr.length() + index) {
                    result = true;
                }

                return result;
            }
        }
    }

    public static String[] splitStr(String key) {
        int clength = key.length();
        int arrCount = (1 + clength) * clength / 2;
        int index = 0;
        String[] strs = new String[arrCount];

        for(int i = 1; i <= clength; ++i) {
            for(int j = 0; j < clength && j + i <= clength; ++j) {
                strs[index++] = key.substring(j, j + i);
            }
        }

        return strs;
    }

    public static String isObjectNull(Object obj) {
        return obj != null && !obj.equals("") && !obj.equals(" ")?obj.toString():"0";
    }

    public static int checkNameLength(String name) {
        int count = 0;

        for(int i = 0; i < name.length(); ++i) {
            if(name.charAt(i) > 122) {
                count += 2;
            } else {
                ++count;
            }
        }

        return count;
    }

    public static String desplayFloat(Double data) {
        String reData = "0";
        if(data.doubleValue() <= 0.0D) {
            reData = "0";
        } else if(data.doubleValue() == 1.0D) {
            reData = "100";
        } else if(data.doubleValue() > 1.0D) {
            data = Double.valueOf(data.doubleValue() - 1.0D);
            data = Double.valueOf(data.doubleValue() * 100.0D);
            data = Double.valueOf((double)Math.round(data.doubleValue()));
            reData = NumberTools.toInteger(data) + "";
        } else {
            data = Double.valueOf(data.doubleValue() * 100.0D);
            data = Double.valueOf((double)Math.round(data.doubleValue()));
            reData = NumberTools.toInteger(data) + "";
        }

        return reData;
    }

    public static String parseScore(String[] scoreTmp) {
        Object[] object = new Object[2];
        StringBuilder sb = new StringBuilder();
        HashMap map = new HashMap();

        for(int tmp = 0; tmp < scoreTmp.length; ++tmp) {
            String count = scoreTmp[tmp];
            sb.append(count);
        }

        if(sb.length() <= 0) {
            return null;
        } else {
            String var10 = sb.toString();
            int var11 = var10.length();

            for(int data = 0; data < var11; ++data) {
                int set = data + 1;
                map.put(var10.substring(data, set), var10.substring(data, set));
            }

            StringBuilder var12 = new StringBuilder();
            Set var13 = map.keySet();
            Iterator i$ = var13.iterator();

            while(i$.hasNext()) {
                String key = (String)i$.next();
                var12.append(key);
            }

            return var12.toString();
        }
    }

    public static String mapToString(Map map) {
        StringBuilder sb = new StringBuilder();
        Set set = map.keySet();
        Iterator i$ = set.iterator();

        while(i$.hasNext()) {
            String key = (String)i$.next();
            sb.append(key).append(",").append((String)map.get(key)).append("|");
        }

        return sb.substring(0, sb.length() - 1);
    }

    public static HashMap StringToMap(String str) {
        HashMap map = new HashMap();
        String[] data = split(str, "|");

        for(int i = 0; i < data.length; ++i) {
            String[] tmp = split(data[i], ",");
            map.put(tmp[0], tmp[1]);
        }

        return map;
    }

    public static String escapeSql(String sqlStr) {
        return StringEscapeUtils.escapeSql(sqlStr);
    }

    public static String escapeBySql(String keyWord) {
        return HtmlUtils.htmlEscape(keyWord);
    }

    public static String escapeByHtml(String keyWord) {
        return HtmlUtils.htmlEscape(keyWord);
    }

    public static String unescapeByHtml(String keyWord) {
        return HtmlUtils.htmlUnescape(keyWord);
    }
}



你可能感兴趣的:(心情)