Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Formatting a Date and parsing it back to Date issue

    I have the following code:

    Code:
    Date date = new Date();
    String formattedDate = DateUtil.format(date, "yyyyMMddHHmm");
    SC.logWarn("formattedDate == " + formattedDate);
    Date parsedDate = DateUtil.parseInput(formattedDate, "yyyyMMddHHmm");
    SC.logWarn("parsedDate == " + parsedDate);
    This produces the following output:
    Code:
    17:09:03.322:MUP9:WARN:Log:formattedDate == 201409011709
    17:09:03.323:MUP9:WARN:Log:parsedDate == null
    How come parseInput() returns null, and not a Date object? Am I missing something obvious?

    SmartClient Version: v10.0d_2014-08-20/Pro Deployment (built 2014-08-21)

    #2
    Parse input parses user input and users do not generally type dates in the datestamp format (201409011709) so that's being correctly rejected as invalid input.

    Comment


      #3
      I understand I was using the DateUtil class for the wrong purpose.
      What I actually needed was com.google.gwt.i18n.client.DateTimeFormat to transform the Date to String and back.

      Comment

      Working...
      X