Skip to Content
author's profile photo Former Member
Former Member

Can I dynamically change the date format of a simple type?

Hi,

I have created A Web Dynpro Table Called 'Arrivals'.

One of the Field in my table is 'Arrival Dateu2019 - Which is of type u201CDateu201D (I have created a simple type giving the representation format as "DD/MM/YYYY" and assigned this simple type to the 'Arrival Date').

When I run this Web Dynpro application.I am getting the output as expected, as shown below

"DD/MM/YYYY"

31/10/2008

05/11/2008

23/10/2008

10/11/2008

My requirement is :

In the applicaiton I have a radio button to choose the Dateformat between "European Format(DD/MM/YYYY)" and "US format", i.e, "MM/DD/YYYY". so that the output now will be

"MM/DD/YYYY"

10/31/2008

11/05/2008

10/23/2008

11/10/2008

So when I select the US format radio button I want to dynamically change the format representation of the simple type to "MM/DD/YYYY"

I cannot use date formatter as Arrival Date is of type 'Date' and more over I have implemented sorting to my table, So if I change it to String , it will sort date as String..

And also I cannot use different value attribute(Say Arrival Date1) which is assigned to another simple type with US format as this will increase the complexity.

Kindly let me know if there is any possible solution for this.

Regards,

Shilpa B.V

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Feb 27, 2009 at 06:33 AM

    Hi

    1.You can achieve this during runtime only thing is that based on the selection of the the RadioButton you have finally populate the values from enumerations. like this

    IWDNodeInfo nodeinfo_dist = wdContext.nodeRegionDetails().getNodeInfo();

    IWDAttributeInfo attributeInfo = nodeinfo_dist

    .getAttribute(IPublicAdminComp.IRegionDetailsElement.DISTRICTCODE);

    ISimpleTypeModifiable districtYype = attributeInfo.getModifiableSimpleType();

    IModifiableSimpleValueSet valueSet_dist = districtYype.getSVServices().getModifiableSimpleValueSet();

    valueSet_dist.clear();

    for (int i = 0; i < wdContext.nodeReturnGetAllDistrict().size(); i++)

    {

    if(RadioButton Option)

    {

    districtYype.setFormat(arg0)

    }

    else if(RadioButton Option)

    {

    districtYype.setFormat(arg0)

    }

    district = wdContext.nodeReturnGetAllDistrict().getReturnGetAllDistrictElementAt(i);

    valueSet_dist.put(district.getSalesOrgCode(), district.getSalesOrgName());

    }

    2. You can escape the populate all the data other than date and then format it ,Just it require understanding of the previous code.

    Best Regards

    Satish Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 27, 2009 at 06:37 AM

    Hi Shilpa,

    You can use the format function of the modifiable simple value set to achieve this.

    modifbale_object.setFormat(Define your format);

    Please check this link:

    This will be definitely of your help:

    http://help.sap.com/javadocs/NW04S/SPS09/dr/com/sap/dictionary/runtime/ISimpleTypeModifiable.html

    I hope this solves your issue!

    Thanks and Reagrds,

    Pravesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2009 at 07:13 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 27, 2009 at 07:19 AM

    Hi,

    Try this code.

    DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
    Date dateString = new java.util.Date();
    Date today = df.parse(dateString);
    java.sql.Date datepass = new java.sql.Date(today.getTime());
    wdContext.currentPersonalDataElement().setdate(datepass );

    By using this you can convert date format to any type.

    Regards,

    H.V.Swathi

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.