google-code-export / gwt-ext

Automatically exported from code.google.com/p/gwt-ext
0 stars 0 forks source link

Format.date should accept java.util.Date #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Ext accepts a Date:

/**
 * Parse a value into a formatted date using the specified format pattern.
 * @param {Mixed} value The value to format
 * @param {String} format (optional) Any valid date format string (defaults
to 'm/d/Y')
 * @return {String} The formatted date string
 */
date : function(v, format){
    if(!v){
        return "";
    }
    if(!(v instanceof Date)){
        v = new Date(Date.parse(v));
    }
    return v.dateFormat(format || "m/d/Y");
},

Original issue reported on code.google.com by mathias....@gmail.com on 26 Jul 2007 at 7:30

GoogleCodeExporter commented 9 years ago
Also, the format is optional, defaults to "m/d/Y". So could you add a 
Format.date
with only 1 argument?

Original comment by mathias....@gmail.com on 26 Jul 2007 at 7:36

GoogleCodeExporter commented 9 years ago
The Format class has String oriented functions. Please use DateUtil for untility
functions for the Date data type. For example DateUtil#format

I've added the convenience method Format.date(String dataStr) where format 
defaults
to "m/d/Y" but the preferred API would be to use DateUtil.format with an 
explicit
format. Just declare a default date format constant in your class and use that 
when
carrying out Date formatting options.

Original comment by sanjiv.j...@gmail.com on 26 Jul 2007 at 10:58