This discussion is archived
2 Replies Latest reply: Jan 16, 2013 9:10 AM by user9326077 RSS

Date format issue

965333 Newbie
Currently Being Moderated
Hi,

I am having an issue with date format. I am trying to change the format of date to dd/MM/yyyy. This is the code I am using:

<invoke name='format'>
<new class='java.text.SimpleDateFormat'>
<s>dd/MM/yyyy</s>
</new>
<ref>global.HireDate</ref>
</invoke>

However, it is throwing an exception: Can't call method format on class java.text.SimpleDateFormat ==> java.lang.IllegalArgumentException: Cannot format given Object as a Date

Can someone throw some light on this?

Thanks in advance...

Edited by: 962330 on Jan 15, 2013 9:57 PM
  • 1. Re: Date format issue
    user243865 Newbie
    Currently Being Moderated
    Are you trying to set the global.HireDate to the current date in that format as a string?

    or are you trying to use it as an argument?

    Perhaps?
                    <set name="global.HireDate">
                        <invoke name="format">
                          <new class="java.text.SimpleDateFormat">
                            &lt;s>dd/MM/yyyy&lt;/s>
                          </new>
                        </invoke>
                    </set>
    I haven't a possibility to test at the moment so I might be far out there :D

    Edited by: Dhurgan on Jan 16, 2013 4:19 PM
  • 2. Re: Date format issue
    user9326077 Newbie
    Currently Being Moderated
    Hi,

    you are missing a "Date" object as parameter to the "format" method of the newly generated java.text.SimpleDateFormat.

    Regards
    Felix

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points