java.util.Date and xsd:date Incompatibility


I have seen various versions of this problem in other posts, but I am starting a new thread hoping that this is already fixed.

The IS service has an output document with a field constrained by XmlSchema (xsd:date) and this is called via WSC from CAF.

Following behaviours are observed.

  1. When you run the IS service in Developer the Date returned is “2006-06-18”
  2. On the CAF screen, the date is displayed as “18/06/2006 00:00:00”

The requirement is to display only the date part as “18/06/2006”

Following approaches were tried.

  1. Used Formatted Date Converter on CAF control and set value pattern as “dd/MM/yyyy” with Time Displayed set to False and everything else is empty.

Result : No change same date time displayed

  1. Used all of the Date Formatting, Parsing in Java.

Result : No change, also get Unparseable Date exception.


  1. Changing the IS service or IS document data type to string and all of that is not an option.

In simple words…

  1. How do we format the IS returning a date type in CAF using either the converters or Java code?

Best regards,

You can do this using Java Code…

  1. First you store your output date from IS in some DATE type data Variable (goto Bindings-> Managed Beans-> yourPortlet/default Right Click on it–> Add–> Data. here give some Property name and set Property type as java.util.Date)

  2. Now write some action() and inside it write java code like this.
    For suppose your propertyName is “dateHolder”, then

    int date=getDateHolder().getDate() // returns Date ex: 18
    int month=getDateHolder().getMonth() // returns Month ex: 06
    int year= getDateHolder().getYear() // returns Year ex: 2006

    now you can store in String as

    String Full_Date= date+"/"+month+"/"+year;

    Hopefully i guess it should work…it worked for me when i am taking input from DateInput and binded it to Date property. Does not matter whether it is from DateInput or IS service it should work…

All da best…try out… :smiley: :stuck_out_tongue: :lol:

Hi Prasad,

Thanks for your reply. I am sure that will work. However, I do not want to take that path or any of the other many options in which we can achieve this using Date and String manipulations / conversions.

The reason is due to
a) its just not the way it should be!
b) sheer volume of screens and fields that are affected by this.
c) maintainability
d) get an understanding of how it is meant to be achieved in the CAF/WS/IS environment.
e) get an understanding of any limitations and workarounds since this is a very basic operation that almost every CAF implementation will have.

I will wait for some more time for replies before I unwillingly want to make it just work in whatever way. :frowning:

best regards,

Hi Raj,
I suppose, from what you say about the “Formatted Date Converter”, that you are showing your “date” field in a text input/output control.
I tried using both a “Date and Time” converter and a “Formatted Date Time”, and both worked fine.

  • Set Time Displayed = false
  • Set Date Pattern = dd/MM/yyyy

I tried as well using a Date Input control, set its properties

  • Display -> Pattern = “dd/MM/yyyy”
  • “Show Time” = false
    and it worked fine. I left the Value -> Value Pattern property empty (used when the property is bound to a String).

hope this helps,

Hi All,

You are not going to believe this !!

The problem is neither with java.util.Date nor xsd:date. It is with CAF control “Formatted Text”. Formatted Date formats a Date object to include “00:00:00” if there is no time in the Date Object. In Firefox, it is rendered as “12:00:00 AM”.

I know you may be asking why did you use Formatted Text instead of Text. The reason is to apply some of the UI aesthetics.

Looks like this is the reason that none of the Conversions were working. Formatted Text probably overrides conversions.

Pretty powerful control eh?

Hope this helps,
Bets regards,