工作总结2019

2019-4-22总结:

1、Freemarker的使用:

       a、??是判断对象是否为null。example: <#if object> 不为null则执行这里的逻辑 </#if>

       b、后台传递过来为Date类型在前台显示的格式转换:

                       Date birthday = new Date();

                       <td>${birthday}?string("yyyy-MM-hh")</td>

       c、<#if strr??> ${str?string}</#if> 就是讲str已字符串的形式输出

       d、<#if strr!"xxx"> 表示strr的默认值为xxx

       e、<#if strr!!> 表示strr的默认值为null

       f、<#assign str="addd"> 就是给str初始化,用于后面freemarker的的使用,比如: <#assign str="addddeee> ${str?substring(0,4)} 结果为:addd

       g、<#inclde "/text.ftl"> 意思是包括该文件。这里的/表示的路径是:因此"/"代表着webapp/路径 

       h、<#list listTest as obj>

       I、${foo?string("yes","no")} 当foo为真的时候,则显示yes,否则为no

       j、<#if empList?size !=0> 判断集合长度不等于0

       k、<@.form 的使用

2019-04-23 总结:

      a、获取当季的第一天,和获取当季的最后一天

               /**
        * 当前季度的开始时间,即2012-01-1 00:00:00
        *
        * @return
        */
       public   Date getCurrentQuarterStartTime() {
           Calendar c = Calendar.getInstance();
           int currentMonth = c.get(Calendar.MONTH) + 1;
           Date now = null;
           try {
               if (currentMonth >= 1 && currentMonth <= 3)
                   c.set(Calendar.MONTH, 0);
               else if (currentMonth >= 4 && currentMonth <= 6)
                   c.set(Calendar.MONTH, 3);
               else if (currentMonth >= 7 && currentMonth <= 9)
                   c.set(Calendar.MONTH, 4);
               else if (currentMonth >= 10 && currentMonth <= 12)
                   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;
       }

      b、获取当季的最后一天

       
       /**
        * 当前季度的结束时间,即2012-03-31 23:59:59
        *
        * @return
        */
       public   Date getCurrentQuarterEndTime() {
           Calendar c = Calendar.getInstance();
           int currentMonth = c.get(Calendar.MONTH) + 1;
           Date now = null;
           try {
               if (currentMonth >= 1 && currentMonth <= 3) {
                   c.set(Calendar.MONTH, 2);
                   c.set(Calendar.DATE, 31);
               } else if (currentMonth >= 4 && currentMonth <= 6) {
                   c.set(Calendar.MONTH, 5);
                   c.set(Calendar.DATE, 30);
               } else if (currentMonth >= 7 && currentMonth <= 9) {
                   c.set(Calendar.MONTH, 8);
                   c.set(Calendar.DATE, 30);
               } else if (currentMonth >= 10 && currentMonth <= 12) {
                   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;
       }

      c、Calendar和Date的转换:

                  //Calendar转化弄成Date类型

                   public static Date calendarToData(int year, int month, int day) {

                           Calendar calendar = Calendar.getInstance();//日历类的实例化

                            calendar.set(year, month - 1, day);//设置日历时间,月份必须减一

                            Date date = calendar.getTime(); // 从一个 Calendar 对象中获取 Date 对象 return date;

                  }

                  System.out.println(calendarToData(2017,3,16));//打印测试

                 //Date类型转成Calendar类型

                  public static Calendar dataToCalendar(Date date) {

                         Calendar calendar = Calendar.getInstance();

                         calendar.setTime(date); return calendar;

                  }

                  Date date = new Date();//直接new对象,获取的是当前时间

                  System.out.println(dataToCalendar(date));//打印测试

 

            d、Date转换成指定String类型的格式

                 SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS");

                  String time = format.format(Calendar.getInstance().getTime());  //这里的话就是把Calendar转成Date类型。

                   System.out.println("完整的时间和日期: " + time);

 

 

2019-04-24总结:

            a、数据库SQL查询的时候: example: t.name = 'jkWess'  AND   (t.sex='1'  OR t.age=32)  AND t.address='111'   

                    这里的话需要把OR的字段用括号括起来。

           b、使用js获取当前时间: var  myDate = new Date();   格式为 2019/4/24

           c、使用js把当前时间转换成String类型: var myDateStr = myDate.toLocaleDateString();

           d、使用js获取页面的某个时间字符串并且把该字符串转换成Date类型:

                     var  strFromPage = $("test").html();    //获取页面的时间字段值

                      var   str = strFromPage.replace(/-/g, '/');  把2019-04-24 转换成 2019/04/24 的时间字符串

                     var strDate = new Date(str); 就把转成2019/04/24 的时间字符串,转成Date类型。

            e、使用js比较两个时间的大小,直接用myDate - strDate   即可比较出,strDate是否在当前时间之前。

            f、在ftl页面中使用js获取后台传递过来的list集合的大小: $(function(){

                                                                                                                 var  size = ${listMap.size()};

                                                                                                         });

            g、使用js去掉字符串里面的指定字符:

                   var  str = "2019-1-12";

                   var  str2 = str.split("-").join("");

                   console.log(str2); //2019112

             h、使用SQL去重(指定字段): select  distinct(name) from table1 ;

             i、SQL优化:当一个字段需要匹配多个值时(a = 1 or a=2 ...) 这个时候要用到  a in(1,2..)

 

 

 

    
 


 

 

                             

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值