8 Replies Latest reply: Jan 13, 2010 12:04 PM by Joren Crauwels RSS

date format dd/MMM/yyyy still a bug?

Joren Crauwels
Currently Being Moderated

Dear all,

 

Is the dd/MMM/yyyy format for a simple type (built-in type date) still a bug in webdynpro?

Issue: When you create a simpletype in the webdynpro dictionary, of type date with format dd/MMM/yyyy it doesnt appear as such in the views.

When i create a simple type, built-in type timestamp, with the same format, it does show as 17/Nov/2009, but the datepicker is missing then.

 

Should i create a SAP message for it? I assume they want to fix this, since they claim to support the formated supported by SimpleDateFormat.

 

Kind regards,

J

  • Re: date format dd/MMM/yyyy still a bug?
    Satish Jhariya
    Currently Being Moderated

    Hi

     

    Format the date object in required format

     

    Try this code

     

               

    String str_date = "11-June-07";
              DateFormat formatter;
              Date date;
             java.sql.Timestamp timeStampDate = null ;
              formatter = new SimpleDateFormat("dd-MM-yyyy");
              try
              {
                   date = (Date) formatter.parse(str_date);
                   timeStampDate = new Timestamp(date.getTime());
                   wdComponentAPI.getMessageManager().reportSuccess("Today is " + timeStampDate);
              }
              catch (ParseException e)
              {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              }
              wdContext.currentContextElement().setDateYtp(timeStampDate);

     

    Best Regards

    Satish Kumar

  • Re: date format dd/MMM/yyyy still a bug?
    Tushar Sinha
    Currently Being Moderated

    Hi Joren,

     

    Are are correct about date picker being a bug in NWDS right not. Date of the format DD/MMM/YYYY would only be supported by simple type when the screen loads for the very first time. Later on modification, the date format wont be changed as per what is defined in the simple type. So, you can raise a request for the same to SAP. In the meantime what you can follow is use DateNavigator UI element in Popup Window which opens on click of a button next to date inputfield. Let this date input field be bound to an attribute of the type string. Using the SimpleDateFormat API convert the entered string to corresponding date in case if valid or to current date if invalid and point the same when user clicks on the button placed next to input field. In the same way convert the date to string of required format on close of the popup window when the date from DateNavigator is selected.

     

    Regards,

    Tushar Sinha

    • Re: date format dd/MMM/yyyy still a bug?
      Joren Crauwels
      Currently Being Moderated

      I found sapnote  1177239 and it says the following:

       

      Reason and Prerequisites
      
      As of Release 7.11, the format templates that are used for parsing and formatting are used from the backend R/3 user settings of the current user wherever possible.
      If no backend is available, the system still does not use the format template of the underlying SimpleType but the one that is described with SHORT in the class java.text.DateFormat. As a result, incompatible behavior may occur if you previously worked with your own format template.
      Solution
      
      Using the available SimpleType, create a modifyable  SimpleType and set the locales of the original type and the format template. The system then takes this template into account for parsing or formatting.
      ...
      ISimpleType si = ...  <<< SimpleType vom Typ time besorgen
      ISimpleTypeModifiable siM = si.cloneType();
      siM.setLocale(si.getLocale());
      siM.setFormat("hh 'o''clock' a");
      siM.parse("12 o'clock PM"); a");

       

      I noticed that even with templates that worked in NW 7.0, the behavior is not the same anymore. Template dd/MM/yyyy is not displayed correctly either.

      Is this because of the explanation in the above note? When i print my current date on the screen in SHORT version, as mentionned in the note, i see the following:  11/18/09

      However, the format in the inputfield is 11/18/2009 and the format in the simple type is yyyy-MM-dd.

       

      So basically my question is, how can i control the format of my date inputfields, without changing them to text inputfields with custom button that opens the datenavigator...

       

      Kind regards.

      J.

      • Re: date format dd/MMM/yyyy still a bug?
        Tushar Sinha
        Currently Being Moderated

        Hi Joren,

         

        The thread doesnt dot speak in specific which format is supported and which is not.

        As per my experience anything (date format) of the sort other than displaying using only digits for displaying days, months and year

        would not be modified as per the representation in the simple type.

        It works for yyyy-MM-dd format

         

        Try this out.

         

        Make a SimpleType of the name Date and give the above format (yyyy-MM-dd) in its representation.

        Bind this simpleType to a context attribute (Va_DateFormat)'s datatype and bind the attribute to the input field.

        And, then put the above code in the wdDoModify of the View Controller. It will work.

        But, yes if you try for MMM representation, it would definitely not be supported by NWDS 7.0 version.

        So, don't go for it right now and better raise an OSS message for the same.

         

             IWDAttributeInfo dtInfo = wdContext.getNodeInfo().getAttribute(IPrivateUIEleCompView.IContextElement.VA__DATE_FORMAT);

             ISimpleType st = dtInfo.getSimpleType();

             ISimpleTypeModifiable sttype = st.cloneType();

             sttype.setLocale(st.getLocale());

         

        Let me know if you are still not done.

         

        Regards,

        Tushar Sinha

  • Re: date format dd/MMM/yyyy still a bug?
    Joren Crauwels
    Currently Being Moderated

    Closed.

    Raised an OSS message @ service.sap.com

Actions