2 Replies Latest reply on May 31, 2011 10:10 AM by PierreSolutions

    DateTimeFormatter.format() and date stored as string

    PierreSolutions Level 2



      I need to display some data in a spark data grid and would like to format a date from that data with a labelFunction calling a DateTimeFormatter's format function.


      The date is stored in my ArrayCollection in the following format '2004-05-03 01:03:52.0'


      my formatter is as follows


      <s:DateTimeFormatter id="dateFormatter" dateTimePattern="YYYY-MM-DD" />


      I would like my label function to return something like


      return "Date: " + dateFormatter.format( item[column.dataField]); // where the item[column.dataField] = "2004-05-03 01:03:52.0"


      The date is coming up blank. I'm thinking I need to convert the string "2004-05-03 01:03:52.0" to a Date object first, then pass that into the format() call.


      Is that the way to go? If so, what's the best way to handle that?