One way to convert a string from yyyy-mm-dd is to use the SimpleDateFormat java.util class like:
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”);
java.util.Date convertedDate = sdf.parse(“2010-11-16”);
I’ve attached a sample portlet application that accepts a user input string, and then generates and displays the date. All date controls use the browser locale by default, unless configured differently.
I could’ve used a converter instead of two properties but i didn’t. It’s your choice.
I’m a newbie about this CAF so not sure about your answer.
My IS service returns a string that contains a date (format yyyy-MM-dd). When I push the control to the screen with this field is only a text field, so the CAF can not automatically Localize since it does not know that a Date.
Can you use any control/converter to say that the string is a Date in the format yyyy-MM-dd and that we and to change the format into the users system locale?
It would be great to have a control to do this otherwise I will have to change my auto-generated MBs to put that code for the localization.
In the example i posted, i’m using a Date-Input control set to read-only. All you need to do is use the Value-Pattern property and give it the format for your the string that you bound to the control: yyyy-MM-dd. (The Value-Pattern has a nice alt text that explains the purpose of that property as well).