具有DateTime的GWT(检查送达日在有效日期) [英] GWT with DateTime ( Checking giving day is in valid days )

查看:168
本文介绍了具有DateTime的GWT(检查送达日在有效日期)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 GWT 中的日期获得丰富的设施问题,就像 JAVA日历对象。但不幸的是,我不能在客户端使用它,因为这不是在仿真课程。我非常懒惰,不仅要编写代码,还要导入另一个库,所以我想通过 GWT 进行准备就绪的功能。



  *条件取决于今天




  • 如果今天< = 3(有效日期范围是 > 上个月的第一天 今天

  • else(有效日期范围是

    这里我的代码...

      private boolean isInValidDateRange(final Date checkDate){
    Date dateDate = new Date();
    int currentDay = Integer.parseInt(DateTimeFormat.getFormat(dd)。format(todayDate));
    Date startDate = null;
    //结束日期总是今天
    日期endDate = new Date();
    if(currentDay< = 3){
    // shift to上个月
    CalendarUtil.addMonthsToDate(todayDate,-1);
    //设置为月的第一天
    CalendarUtil.setToFirstDayOfMonth(todayDate);
    startDate = todayDate;

    }
    else {
    //设置为月的第一天
    CalendarUtil.setToFirstDayOfMonth(todayDate);
    startDate = todayDate;
    }
    return(CalendarUtil.getDaysBetween(startDate,checkDate)> = 0&&
    CalendarUtil.getDaysBetween(checkDate,endDate)> = 0);
    }

    我多次搜索我的问题的答案。但是大部分都是导致 Java日历 对象。



    我的问题是如何通过简单的方法或我可以把它转换成简单的代码吗?

    解决方案

    您可以使用Sencha GXT DateWrapper而不是实现Java日历



    date wrapper docs


    I want to get rich facilities concerns with Date in GWT as like JAVA Calendar Object. But unfortunately , I can't use it in client side due to that is not in Emulation Classes. I am so lazy not only to write hard code but also to import another libraries , so I want to get ready made functions these are made by GWT.

    My problem is checking given day , is that in valid days range ?

    *Condition depends on Today
    

    • If today <= 3 ( valid days range is from fist day of previous month to today)
    • else ( valid days range is from fist day of this month to today)

    Here my codes...

        private boolean isInValidDateRange(final Date checkDate) {
        Date todayDate = new Date();
        int currentDay = Integer.parseInt(DateTimeFormat.getFormat("dd").format(todayDate));
        Date startDate = null;
        // End date will always today
        Date endDate = new Date();
        if (currentDay <= 3) {
            // shift to previous month
            CalendarUtil.addMonthsToDate(todayDate, -1);
            // set to first day of month
            CalendarUtil.setToFirstDayOfMonth(todayDate);
            startDate = todayDate;
    
        }
        else {
            // set to first day of month
            CalendarUtil.setToFirstDayOfMonth(todayDate);
            startDate = todayDate;
        }
        return (CalendarUtil.getDaysBetween(startDate, checkDate) >= 0 && 
                CalendarUtil.getDaysBetween(checkDate,endDate) >= 0);
    }
    

    I googled many times to get answers for my problems. But most of them lead to Java Calendar Object.

    My question is how to get it by easy way or can I convert it to simply codes?

    解决方案

    you can use Sencha GXT DateWrapper instead of implement Java Calendar

    date wrapper docs

    这篇关于具有DateTime的GWT(检查送达日在有效日期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆