精华内容
下载资源
问答
  • Validate date

    2020-11-26 07:43:18
    <p>A lot of API manipulate date. <p>How can I use native functionnality of your tool to do it ? Or do I need to write my own extension ? <p>Thx <p>Regards</p><p>该提问来源于开源项目:svanoort/...
  • Validate Date

    2014-11-07 17:30:22
    * Validate date by date format. * * @param dateStr * the date str * @param pattern * the pattern * @return the boolean * @throws ParseException * the parse exception */ 5.public ...
    校验一个文本文件中某个字符串(A)是否是合法日期的方法:

    1.A应该不能为空,
    2.A应该是一个纯数字的字符串,且其长度和日期格式的长度相匹配,
    3.利用字符串的转换函数,将A按照日期格式转换成日期B
    4.利用日期转换函数,将B按照日期格式转换成字符串C,
    5.比较A和C是否相等,如果不相等,则A不是一个合法的日期,否则A是

    1.StringUtils.isEmpty(Object);

    2.
    private static final String NUMBER_FORMAT_REGEX = "(^\\d*[.]?\\d$)";
    private static final Pattern NUMBER_FORMAT_PATTERN = Pattern.compile(NUMBER_FORMAT_REGEX);

    /**
    * Validate digit format.
    *
    * @param number
    * the number
    * @return the boolean
    */
    public Boolean validateDigitFormat(String number) {
    return NUMBER_FORMAT_PATTERN.matcher(number).matches();
    }


    DateUtils:
    /**
    * Parses the str to date.
    *
    * @param dateStr
    * the date str
    * @param pattern
    * the pattern
    * @return the date
    * @throws ParseException
    * the parse exception
    */
    3.public static Date parseStrToDate(String dateStr, String pattern) throws ParseException {
    Date result = null;
    if (StringUtils.isNotEmpty(dateStr)) {
    return new SimpleDateFormat(pattern).parse(dateStr);
    }
    return result;
    }

    /**
    * Parses the date to str.
    *
    * @param date
    * the date
    * @param pattern
    * the pattern
    * @return the string
    */
    4.public static String parseDateToStr(Date date, String pattern) {
    String result = null;
    if (date != null) {
    return new SimpleDateFormat(pattern).format(date);
    }
    return result;
    }

    /**
    * Validate date by date format.
    *
    * @param dateStr
    * the date str
    * @param pattern
    * the pattern
    * @return the boolean
    * @throws ParseException
    * the parse exception
    */
    5.public Boolean validateDateByDateFormat(String dateStr, String pattern) throws ParseException {
    Date strToDate = DateUtils.parseStrToDate(dateStr, pattern);
    String dateToStr = DateUtils.parseDateToStr(strToDate, pattern);
    return strToDate.equals(dateToStr);
    }
    展开全文
  • Validate date ranges

    2020-12-09 02:16:58
    <p>This PR adds an optional <code>validate_in_range</code> behaviour, that makes sure user provided date input is within the allowed range defined by <code>#from</code> and <code>#to</code> methods. ...
  • <div><p>Validate Date of Death to not allow future dates.</p><p>该提问来源于开源项目:LibreHealthIO/lh-ehr</p></div>
  • I think it would be nice to have ability validate date string without time using () decorator. For example, '2000-07-26', not '2000-07-26T00:00:01.967Z'. Cannot find how to do that not...
  • t validate date format in draft v4. <p>It looks like the cause is https://github.com/Julian/jsonschema/blob/aaee55c9f6eea1abd37ca7a2537d586f8940971c/jsonschema/_format.py#L233, which only adds the ...
  • validate date iso string

    2021-01-12 10:15:00
    <div><p>Creating validation for ISOString date</p><p>该提问来源于开源项目:typestack/class-validator</p></div>
  • java validate date

    2019-01-31 14:24:00
    public boolean isDateValidDDMMYYYY(String date) { String DATE_FORMAT = "ddMMyyyy"; try { DateFormat df = new SimpleDateFormat(DATE_FORMAT); ...
        public  boolean isDateValidDDMMYYYY(String date) 
        {
            String DATE_FORMAT = "ddMMyyyy";
    
                try {
                    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                    df.setLenient(false);
                    df.parse(date);
                    return true;
                } catch (ParseException e) {
                    return false;
                }
        }
         
        public  boolean isDateValidYYYYMMDD(String date) 
        {
            String DATE_FORMAT = "yyyyMMdd";
    
                try {
                    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                    df.setLenient(false);
                    df.parse(date);
                    return true;
                } catch (ParseException e) {
                    return false;
                }
        }
        

     

    public static boolean isDateValidTime(String time) 
        {
            String DATE_FORMAT = "HHmmss";
    
                try {
                    DateFormat df = new SimpleDateFormat(DATE_FORMAT);
                    df.setLenient(false);
                    df.parse(time);
                    return true;
                } catch (ParseException e) {
                    return false;
                }
        }

     

    转载于:https://www.cnblogs.com/kakaisgood/p/10341822.html

    展开全文
  • Do not validate date-time

    2020-11-27 22:57:28
    <div><p>I have an error to validate a date-time property. Value of datetime is "2015-09-28T10:40:00+0200".</p><p>该提问来源于开源项目:tdegrunt/jsonschema</p></div>
  • <div><p>Someone filed a support ticket ...<p>We should verify that month, date, and year are integers and log an error otherwise.</p><p>该提问来源于开源项目:NUKnightLab/TimelineJS3</p></div>
  • m trying to validate a custom date/time field on an order. The validator runs but throws the following error. <p><code>DateTime::createFromFormat() expects parameter 2 to be string, object given...
  • <div><p>Ensure the hidden input storing the value for the dateTimePicker is <code>:required, which prevents the form from saving. This value is also passed down into the template UI created by the JS ...
  • If the input Date format is 'YYYY/MM/DD', the current logic directly call math floor on this value will return a wrong date as output. Added some validation logic before pass through the ...
  • JQuery validate date 日期校验问题

    千次阅读 2016-04-21 14:06:06
    做JS API时,发现JQuery校验插件的一个时间校验问题。  最终目的:输入一个字符串,校验如果是... 做法:$("#validateForm").validate({ debug : true, rules : {"date" : { isDate : true }

      做JS API时,发现JQuery校验插件的一个时间校验问题。

      最终目的:输入一个字符串,校验如果是正确的日期,则通过,否则给出提示。

      做法:

    $("#validateForm").validate({
    				debug : true,
    				rules : {"date" : {
    						isDate : true
    					     }
                                      },
    				messages : {
    					"date" : {
    						date : "日期格式不正确"
    					}
    				}
      效果:输入201300 报错,2014/01/01 正确  2014-01-01正确  20140101错误,这个地方可以做格式转换

      问题:输入2016-04-31,竟然校验通过了,一脸黑线

      原因:特意调出了JQuery validate的框架代码,原来是通过校验new Date(value)来判断日期是否有效。

    // http://docs.jquery.com/Plugins/Validation/Methods/date
    		date: function(value, element) {
    			return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
    		}
                 然后,就试了一下new Date()函数
    new Date("2016-04-31")
    Sun May 01 2016 08:00:00 GMT+0800 (中国标准时间)
                new Date()会把4月31号直接转换成5月1号,只能说太智能了,但这种显然不是我们想要的效果

      解决方法:解决就从new Date()下手,转换成日期后,查出日期的月份,如果此时的月份和传入日期的月份不一致,说明日期又问题,解决!

    //日期
    jQuery.validator.addMethod("isDate", function(value, element){
    	var ereg = /^(\d{1,4})(-|\/)(\d{1,2})(-|\/)(\d{1,2})$/;
    	var r = value.match(ereg);
    	if (r == null) {
    		return false;
    	}
    	var d = new Date(r[1], r[3] - 1, r[5]);
    	var result = (d.getFullYear() == r[1] && (d.getMonth() + 1) == r[3] && d.getDate() == r[5]);
    	
    	return this.optional(element) || (result);
    }, "请输入正确的日期");

    展开全文
  • <div><p>This needs discussion imo, because it includes a workaround</p><p>该提问来源于开源项目:wayneashleyberry/wunderline</p></div>
  • ^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$ ...

    ^(((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00)))$

    转载于:https://www.cnblogs.com/moluoyizu/archive/2011/03/31/2000798.html

    展开全文
  • Validate moment date

    2021-01-07 10:53:02
    <div><p>Hi, without this checking i get a "calendar-day-Invalid date" ids in day elements, and checking fix it.</p><p>该提问来源于开源项目:kylestetz/CLNDR</p></div>
  • 1166 validate imagery date

    2020-12-01 12:09:11
    <p>This change uses the QT library to validate the date of an imagery resource. When an invalid date is entered (ex: 2019-02-29) and the user attempts to save the resource, an error message appears ...
  • <ol><li><em>show from</em> is activated</li><li><em>show until</em> is activated</li><li><em>both options</em> are activated, but <em>show until</em> must be a higher date than <em>show from</em></li>...
  • Validate the date format

    2019-10-04 06:50:36
    Validate the date format function checkdate(input) { var validformat = /^\d{2}\/\d{2}\/\d{4}$/; //Basic check for format validity var returnval =...
  • Validate on Date part only

    2021-01-12 09:40:21
    s best to also convert to only Date in the Validate methods of the DatePicker. <h3>Issues Resolved ### <ul><li>fixes #5784</li></ul> <h3>API Changes <p>Changed: - return (DateTime)value >= (...
  • Therefore what i did with my phpMyAdmin is that, when enters the date time manually it will validate using javascript and show the error instantly. Therefore it saves more time and improve the ...
  • <div><p>When passing empty string to date field, its not correctly validated and returned as validation error. <pre><code>python class EventModel(models.Model): name = models.TextField() ...
  • new \Zend_Validate_Date('Y-m-d'); var_dump($validator->isValid('2015-05-01|DEFAULT')); $validator = new \Zend_Validate_Date(); var_dump($validator->isValid('2015-05-01|...
  • 可能会帮助:) 支持语言:English
  • <div><p>This fixes one of the two tests that fail when switching to angular#1.3.0-rc.2. The viewValue returns a string value each time but the modelValue returns the object...angular-ui/ui-date</p></div>
  • <div><p>If the last date of payments is set to a value <em>before</em> the end of the presale period, users can buy tickets but never pay them. This is probably not a situation anyone wants to have :)...
  • the date will not be checked</li><li>while updating the status from draft to published will trigger validate_date and change the state to draft if date is behind current date and time</li></ul> ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 3,788
精华内容 1,515
关键字:

validatedate