`
收藏列表
标题 标签 来源
textSlider
(function($){
	$.fn.textSlider = function(settings){ //接口   
            settings = jQuery.extend({//设定参数:滚动速度、滚动行数、停顿时间
                speed : "normal",
                line : 2,
                timer : 3000
            }, settings);
            return this.each(function() {
                $.fn.textSlider.scllor( $( this ), settings );
            });
        };
	$.fn.textSlider.scllor = function($this, settings){
            var ul = $("ul:eq(0)",$this );//定位
            var timerID;
            var li = ul.children();//所有li
            var liHight=$(li[0]).height();//一个li的高度
            var upHeight=0-settings.line*liHight;//向上滚动一次的高度
            var scrollUp=function(){
                ul.animate({marginTop:upHeight},settings.speed,function(){//参数,滚动速度,回调函数
                    for(i=0;i<settings.line;i++){//根据设定的滚动行数决定移动到列表末尾的行数
                        ul.find("li:first",$this).appendTo(ul);
                    }
                    ul.css({marginTop:0});
                });
            };
            var autoPlay=function(){//滚动
                timerID = window.setInterval(scrollUp,settings.timer);//每隔timer时间,调用一次scrollUp函数
            };
            var autoStop = function(){//停止
                window.clearInterval(timerID);
            };
            
            ul.hover(autoStop,autoPlay).mouseout();//鼠标悬浮时 停止滚动,触发
	};
})(jQuery);


//热门书籍

		$.getJSON("book!indexHotBook.action",function(data){

	        	var listBook = data.listBook;

				$.each(listBook,function(i,n){

					$(".tx_list1").append("<li><a onfocus='this.blur()' href='book!bookDuplicate.action?BNo="+n[0]+"' title='"+n[1]+"' target='f'>"+n[1]+"</a></li>");

			});

			var len=$(".tx_list1 li").length;

				if(len>10){

				$("#scroll1").textSlider({line:3,speed:900,timer:3500});

				}

		});
向左移动-公告
            <div id="marquees" class="left">
                <a class="a1" href="Notice.jsp">应届生现场招聘会通知    </a>
               <a class="a1" href="Notice.jsp">有关2011应届生报到入职的公告    </a>
                <a class="a1" href="Notice.jsp">有关已签约应届生岗位分配    </a>
                <a class="a1" href="Notice.jsp">有关已签约应届生实习和报到安排    </a>
                <a class="a1" href="Notice.jsp">有关2011应届生户口、档案办理及党组织关系转移的公告    </a>
            </div>

                
     <script   type="text/javascript" language="javascript">
                  marqueesWidth=500;    //内容区宽度度
                  stopscroll=false;    //这个变量控制是否停止滚动
                  with(marquees){
                      noWrap=true;    //这句表内容区不自动换行
                      style.width=marqueesWidth;    //于是我们可以将它的宽度设为0,因为它会被撑大
                      style.height=0;
                      style.overflowX="hidden";    //滚动条不可见
                      onmouseover=new    Function("stopscroll=true");    //鼠标经过,停止滚动
                      onmouseout=new    Function("stopscroll=false");    //鼠标离开,开始滚动
                  }
                  //这时候,内容区的高度是无法读取了。下面输出一个不可见的层"templayer",稍后将内容复制到里面:
                  document.write('<div    id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
                  function    init(){    //初始化滚动内容
                      while(templayer.offsetWidth<marqueesWidth){
                          templayer.innerHTML+=marquees.innerHTML;
                      }    //把"templayer"的内容的“两倍”复制回原内容区:
                      marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
                      //设置连续超时,调用"scrollUp()"函数驱动滚动条:
                      setInterval("scrollUp()",20);
                  }
                  document.body.onload=init;
                  preTop=0;    //这个变量用于判断滚动条是否已经到了尽头
                  function    scrollUp(){    //滚动条的驱动函数
                      if(stopscroll==true)    return;    //如果变量"stopscroll"为真,则停止滚动
                      preTop=marquees.scrollLeft;
                      marquees.scrollLeft+=1;
                      //如果滚动条不动了,则向上滚动到和当前画面一样的位置
                      //当然不仅如此,同样还要向下滚动一个像素(+1):
                      if(preTop==marquees.scrollLeft){
                          marquees.scrollLeft=templayer.offsetHeight-marqueesWidth+1;
                      }
                  }
            </script>
ZTree CheckBox 选中操作
 $(document).ready(function(){
        zTree = $("#tree").zTree(setting, zTreeNodes);;
    });
    var zTree;
    var setting;
    var zTreeNodes =[];
    setting = {
        checkable: true,
        async: true,
        asyncUrl: "TreeCourseNight.jsp",
        showLine: true,
        asyncParam: ["prod_id"],
        callback:{
            //click:zTreeOnClick,
            change:zTreeOnChange
        }
    };

    function refreshTree() {
        if($("#trainTime").val() =="非工作日白天"){
            setting.asyncUrl = "TreeCourseDay.jsp";
            zTree1 = $("#tree").zTree(setting, zTreeNodes);
        }else{
            setting.asyncUrl = "TreeCourseNight.jsp";
            zTree1 = $("#tree").zTree(setting, zTreeNodes);
        }
    }
       
    var  stra = "";
    function zTreeOnChange(){
        var tmp =  zTree.getChangeCheckedNodes();
        var str = "";
        var strCourse = "";
        for (var i=0; i<tmp.length; i++) {
            // alert(tmp[i].name);
            if(tmp[i].layer_num == 3){
                str = str +tmp[i].parentNode.name+"--"+tmp[i].name+","; 
            };
            if(tmp[i].layer_num == 2){
                strCourse = strCourse + tmp[i].name+","; 
            }
        }
        if(str != ""){
            str = str.slice(0,str.lastIndexOf());
            var strSplit = str.split(",");
            $("#mk").append("<br/>");
            if(stra !=""){
                $("#mk").empty();          //empty()移出匹配对象的子节点,remove(),移出匹配对象
                for(var j= 0; j<strSplit.length;j++){
                    $("#mk").append('<input style="display:none;" value="'+strSplit[j]+'"/>');
                }
            }else{
                for(var j= 0; j<strSplit.length;j++){
                    $("#mk").append('<input style="display:none;" value="'+strSplit[j]+'"/>');
                }
            }
            stra = str;
        }else{
            $("#mk").empty(); 
        }
                
        if(strCourse != ""){
            strCourse = strCourse.slice(0,str.lastIndexOf());
            $("#course").val(strCourse);    
        }else{
            $("#course").val("");
        }
    }


<div style="padding-right:478px;">
                <p style="width:150px;font-size:14px;background-color:#F8F8F8;">培训课程及模块选择:</p>
            </div>
            <div style="height:365px;margin-left: 300px;">
                <div style="height:363px;padding:10px,0,10px,10px;;text-align:left;background: url(../public/img/img/zTreeDemo_background.jpg) no-repeat;">
                    <ul id="tree" class="tree" style="overflow-x:auto;overflow-y:scroll;width:220px;height:340px;"></ul>
                </div>
            </div>

 
                <div style="padding-right:80px;">
                    <label style="font-size:14px;background-color:#F8F8F8;width:150px;">您选择的课程有:</label>
                    <input id="course" name="course" style="width:400px;"/>
                </div>
                <div style="padding-right:488px;">
                    <label id="mokuai" style="font-size:14px;background-color:#F8F8F8;width:150px;">您选择的课程模块有:</label>
                    <div id="mk"></div>
                </div>
  
两级动态加载下拉列表
$(document).ready(function(){
        $.ajax( {
            url : "../public/xml/course.xml",
            success : function(xml) {
                $(xml).find("area").each(function() {
                    var t = $(this).attr("name");//this->
                    $("#suitArea").append("<option>" + t + "</option>");
                });
            }
        });
        $("#suitArea").change(function() {
            $("#subject>option").remove();
            var pname = $("#suitArea").val();
            $.ajax({
                url:"../public/xml/course.xml",
                success : function(xml) {
                    $(xml).find("area[name='" + pname+ "']>subject").each(
                    function() {
                        $("#subject").append(
                        "<option>"+ $(this).text()+"</option>");});
                }
            });
        });
        
        
    });


<td class="td1"> <label>适用范围:</label></td>
                    <td>
                        <select id="suitArea" name="suitArea" class="nodeSelect">
                            <option>请选择</option>
                        </select>
                        <span class="red">*</span>
                    </td>
                </tr>
                <tr>
                    <td class="td1"><label>课程名称:</label></td>
                    <td>
                        <select id="subject" name="subject" class="nodeSelect">
                        </select>
                        <span class="red">*</span>
                    </td>


xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<areas>
    <area name="通用类课程">
        <subject></subject>
        <subject>企业文化</subject>
        <subject>认真度</subject>
        <subject>有效沟通</subject>
        <subject>人力资源管理</subject>
        <subject>安全环保</subject>
        <subject>法律(销售、采购)</subject>
        <subject>法律(售后)</subject>
        <subject>法律(研发)</subject>
        <subject>法律(软件)</subject>
        <subject>法律(广告)</subject>
        <subject>法律(品质)</subject>
        <subject>法律(管理)</subject>
    </area>
    <area name="汽车产业群课程">
        <subject></subject>
        <subject>汽车英语</subject>
        <subject>汽车基础知识</subject>
        <subject>项目管理(汽车)</subject>
        <subject>财务(汽车)</subject>
        <subject>计划物料控制(汽车)</subject>
        <subject>现场与5S(汽车)</subject>
        <subject>品质体系(汽车)</subject>
        <subject>品质工具(汽车)</subject>
        <subject>IE-消除不良品浪费(汽车)</subject>
        <subject>IE-消除过量生产浪费(汽车)</subject>
        <subject>IE-消除搬运浪费(汽车)</subject>
        <subject>IE-消除过分加工与多余工序浪费(汽车)</subject>
        <subject>IE-降低库存浪费(汽车)</subject>
        <subject>IE-消除动作浪费(汽车)</subject>
        <subject>IE-消除等待浪费(汽车)</subject>
    </area>
    <area name="IT产业群课程">
        <subject></subject>
        <subject>IT基础知识</subject>
        <subject>IT英语</subject>
        <subject>研发项目管理(IT)</subject>
        <subject>产销项目管理(IT)</subject>
        <subject>财务(IT)</subject>
        <subject>计划物料控制(IT)</subject>
        <subject>现场管理与5S(IT)</subject>
        <subject>品质体系(IT)</subject>
        <subject>品质工具(IT)</subject>
        <subject>工业工程(IT)</subject>
    </area>
</areas>

简单的表格操作
function add(src) {
          var plusB = parseFloat(src.value) + parseFloat(document.getElementById('tab').rows[src.parentNode.parentNode.rowIndex].cells[7].innerHTML);
	      document.getElementById('tab').rows[src.parentNode.parentNode.rowIndex].cells[9].childNodes[0].value = number_format(plusB,4);
       }
     
       function checkAndSubmit(){
          var tableAdd = document.getElementById('tab');
          var rowNum = tableAdd.rows.length;
          var addTotal = 0;
          var add =0;
          var i;
          for(i = 2;i<rowNum;i++){   
            if(tableAdd.rows[i].cells[8].childNodes[0].value != ""){
              add = tableAdd.rows[i].cells[8].childNodes[0].value;
            }else{
              add =0;
            }
            addTotal =  parseFloat(addTotal)+parseFloat(add);
          }
          if(addTotal>0){
              alert("调整点数之和不能大于0!");
          }else{
              document.form1.submit();
          }   
     }
ZTree的使用
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>请选择专业名称代码</title>
        <link rel="stylesheet" href="<%=application.getContextPath()%>/resources/css/zTreeStyle.css" type="text/css" />
        <link rel="stylesheet" href="<%=application.getContextPath()%>/resources/css/campus.css" type="text/css" />

        <script type="text/javascript" src="<%=application.getContextPath()%>/resources/js/jquery-1.4.2.js"></script>
        <script type="text/javascript" src="<%=application.getContextPath()%>/resources/js/jquery-ztree-2.5.js"></script>


        <script type="text/javascript">
            $(document).ready(function(){
                zTree = $("#tree").zTree(setting, zTreeNodes);;
            });
            var zTree;
            var setting;
            var zTreeNodes =[];
            setting = {
                async: true,
                asyncUrl: "TreeSchool.jsp",
                showLine: true,
                //                asyncParam: ["prod_id"],
                callback:{
                    click:zTreeOnClick
                    //                    asyncSuccess: zTreeBeforeAsync
                }
            };

            function zTreeOnClick(){
                $("#school").val(zTree.getSelectedNode().name);
                $("#num").val(zTree.getSelectedNode().prod_code);
            }

            function toParentValue(){
                window.parent.document.getElementById("a0814Show").value = $("#school").val();
                window.parent.document.getElementById("a0814").value = $("#num").val();
                window.parent.$.nyroModalRemove();
            }
            function queryInfo(){
                $.getJSON("QuerySchool.jsp", {value:$("#querySchool").val()}, function(json){
                    if(json != null){
                        $('#info').append('<a href="javascript:;" style="margin-left:20px;"               code="'+json.code+'">'+json.name+'</a>');
                        $('#info a').click(function(){
                            var $obj=$(this);
                            $('#num').val($obj.attr('code'));
                            $('#school').val($obj.text());
                        })
                    }else{
                        alert("没有您要搜索的学校,您可选择“其他院校”!");
                    }
                });
            }
        </script>
    </head>
    <body style="font-size:12px;">
        <form action="" method="post">
            <div class="panel_box login">
                <div id="beforeTree">
                    <p style="color:red">由于学校较多,请稍候!</p>
                    <label>您选择的学校名称:</label><br/>
                    <input id="school" name="school" style="width:200px;"/><br/>
                    <label>您选择的学校名称对应的代码:</label><br/>
                    <input id="num" name="num" style="width:200px;"/>
                    <input type="button" id="confirm" name="confirm"  onClick="toParentValue()" value="确定"/>
                </div>
                <hr>
                <div>
                <label>请输入您就读学校的名称:</label><br/>
                <input id="querySchool" name="querySchool" style="width:200px;">
                <input type="button" id="query" name="query" onclick="queryInfo()" value="搜索">
                </div>
                <div id="info"></div>
                <hr>
                <div><ul id='tree' class='tree'></ul></div>
            </div>
        </form>
    </body>
</html>
jqGrid
<%@ page pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jqGrid Demos</title>
    <link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/jquery-ui-1.8.12.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<%=application.getContextPath()%>/resources/jqcss/ui.multiselect.css" />


    <script src="<%=application.getContextPath()%>/resources/js/jquery-1.4.2.min.js" type="text/javascript" ></script>
    <script src="<%=application.getContextPath()%>/resources/jqgrid/grid.locale-cn.js" type="text/javascript"></script>
    <script type="text/javascript">
        $.jgrid.no_legacy_api = true;
        $.jgrid.useJSON = true;
    </script>
    <script src="<%=application.getContextPath()%>/resources/jqgrid/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="<%=application.getContextPath()%>/resources/jqgrid/jquery-ui-1.8.12.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#list4").jqGrid({
                url:"Jqgrid.jsp",
                mtype: "GET",
                datatype: "json",
                height: 250,
                colNames:['序号','日期', '姓名', '数量A','数量B','总和','备注'],
                colModel:[
                    {name:'id',index:'id', width:30, sorttype:"int"},
                    {name:'invdate',index:'invdate', width:90, sorttype:"date"},
                    {name:'name',index:'name', width:100},
                    {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
                    {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},
                    {name:'total',index:'total', width:80,align:"right",sorttype:"float"},
                    {name:'note',index:'note', width:150, sortable:false}
                ],
                rowNum:4,
                rowList:[4,8,12],
                pager: '#pager2',

                multiselect: true,
                caption: "Manipulating Array Data"
            });
//            var mydata = [
//                {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
//                {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
//                {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
//                {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
//                {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
//                {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
//                {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
//                {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
//                {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
//            ];
//            for(var i=0;i<=mydata.length;i++){
//                jQuery("#list4").jqGrid('addRowData',i+1,mydata[i]);
//            }
        });
    </script>
</head>
<body>
    <table id="list4"></table>
    <div id="pager2"></div>
</body>

package hr.recruit.views.info;

import java.util.Map;


public class test {

    public void onLoad(Map request, Map session) {
        StringBuilder sb = new StringBuilder();
        sb.append("[{id:").append('"').append("1").append('"')
                .append(",invdate:").append('"').append("2007-10-01").append('"')
                .append(",name:").append('"').append("test").append('"')
                .append(",note:").append('"').append("note").append('"')
                .append(",amount:").append('"').append("200.00").append('"')
                .append(",tax:").append('"').append("10.00").append('"')
                .append(",total:").append('"').append("210.00").append('"')
                .append("}]")
                ;
        request.put("list", sb.toString());
    }

}



package hr.recruit.views.info;

import hr.recruit.util.BeanUtil;
import java.util.Map;


public class Jqgrid {

    public String onLoad(Map request, Map session) {
        StringBuilder sb = new StringBuilder();
        sb.append("{total:").append('"').append("1").append('"')
                .append(",page:").append('"').append("1").append('"')
                .append(",records:").append('"').append("1").append('"')
                .append(",rows:")
                .append("[{id:").append('"').append("1").append('"').append(",cell:")
                .append("[").append('"').append("1").append('"')
                .append(",").append('"').append("2007-09-01").append('"')
                .append(",").append('"').append("dxb").append('"')
                .append(",").append('"').append("note3").append('"')
                .append(",").append('"').append("400.00").append('"')
                .append(",").append('"').append("400.00").append('"')
                .append(",").append('"').append("430.00").append('"')
                .append("]")
                .append("}]}");
        BeanUtil.responseAjax(sb.toString());
        return "ajax";
    }
}
DateUtil
package hr.recruit.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;


public class DateUtil {
    /**
     * 将yyyy-MM-dd HH:mm 类型的字符串转换成日期
     * @param source
     * @return
     */
    public static Date getDateFromString(String source) {
        Date date = null;

        if(! source.contains("-"))
            return null;
        
        try {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            date = sf.parse(source);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return date;
    }

    /**
     * 将yyyy-MM-dd 或 yyyy/MM/dd类型的字符串转换成日期
     * @param source
     * @return
     */
    public static Date getDateFromShortString(String source)  {
        if(source == null || source.isEmpty())
            return null;
        
        Date date = null;       
        SimpleDateFormat sf = null;

        if( source.contains("-")){
            sf = new SimpleDateFormat("yyyy-MM-dd");
        }else if(source.contains("/")){
            sf = new SimpleDateFormat("yyyy/MM/dd");
        }else{
            throw new RuntimeException("字符串:"+ source+ "转化为日期类型出错!!!");
        }

        try {
             
            date = sf.parse(source);
        } catch (Exception ex) {
            throw new RuntimeException("字符串:"+ source+ "转化为日期类型出错!!!");
        }
        return date;
    }

     /**
     * 取得两个日期间相隔多少天
     * @param date1
     * @param date2
     * @return
     */
    public static int getBetweenDays(Date date1, Date date2) {
        long DAY = 24L * 60L * 60L * 1000L;
        return (int) ((date2.getTime() - date1.getTime()) / DAY);
    }

        /**
     * 将日期转换成yyyy-MM-dd类型的字符串
     * @param date
     * @return
     */
    public static String toShortString(Date date) {
        String retString = "";
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        if (date != null) {
            retString = sf.format(date);
        }
        return retString;
    }

    /**
     * 将日期转换成yyyyMMdd类型的字符串
     * @param date
     * @return
     */
    public static String toShortString8(Date date) {
        String retString = "";
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
        if (date != null) {
            retString = sf.format(date);
        }
        return retString;
    }

    /**
     * 将日期转换成yyyyMMdd类型的字符串
     * @param date
     * @return
     */
    public static String toLongString(Date date) {
        String retString = "";
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        if (date != null) {
            retString = sf.format(date);
        }
        return retString;
    }

    
    /**
     * 得到今天的开始时刻
     * @param date
     * @return
     */
    public static String getMorning() {
        String ret = toShortString(new Date());
        ret += " 00:00:00";
        return ret;
    }

    /**
     * 得到今天的最后时刻
     * @param date
     * @return
     */
    public static String getNight() {
        String ret = toShortString(new Date());
        ret += " 23:59:59";
        return ret;
    }

    public static Date addDay(Date date, int days) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.DATE, days);
        return c.getTime();
    }
    

    public static Date addHour(Date date, int hour) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.HOUR, hour);
        return c.getTime();
    }

    /**
     * 取得上个月最后一天23:59:59的日期
     * @param date
     * @return
     */
    public static Date getLastTimeInLastMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.MONTH, -1);
        int lastDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
        c.set(Calendar.AM_PM, 0);
        c.set(Calendar.DATE, lastDay);
        c.set(Calendar.HOUR, 23);
        c.set(Calendar.MINUTE, 59);
        c.set(Calendar.SECOND, 59);
        return c.getTime();
    }

    /**
     * 取得昨天的日期
     * @param date
     * @return
     */
    public static Date getYesterday() {
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());
        c.add(Calendar.DATE, -1);
        
        return removeHMS(c.getTime());
    }

    

    /**
     * 取得指定日期那个月份的第一天
     * @param date
     * @return
     */
    public static Date getFirstDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);

        int minDayNum = c.getActualMinimum(Calendar.DATE);
        c.set(Calendar.DATE, minDayNum);

        return c.getTime();
    }

    /**
     * 取得指定日期那个月份的第一天
     * @param date
     * @return
     */
    public static Date getFirstDayOfMonth() {
        Calendar c = Calendar.getInstance();
        c.setTime(new Date());

        int minDayNum = c.getActualMinimum(Calendar.DATE);
        c.set(Calendar.DATE, minDayNum);

        return c.getTime();
    }

    public static int getQuarter(Date date){

        return  date.getMonth() / 3 + 1;

    }

     public static int getMonth(Date date){

        return  date.getMonth() +  1;

    }

      public static int getYear(Date date){

        return  date.getYear() +  1900;

    }


    /**
     * 设置时间的时分秒为0
     * @param date
     * @return
     */
    public static Date removeHMS(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.AM_PM, 0);
        c.set(Calendar.HOUR, 0);
        c.set(Calendar.MINUTE, 0);
        c.set(Calendar.SECOND, 0);
        c.set(Calendar.MILLISECOND, 0);
        return c.getTime();
    }

    public static Date getDateGMT8(){
          Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
          return c.getTime();

          // int hour = c.get(Calendar.HOUR_OF_DAY);
    }

    public static Calendar getCalendarGMT8(){
          Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT+8"));
          return c;
    }
}
Global site tag (gtag.js) - Google Analytics