Skip to Content
avatar image
Former Member

How to get a date picker according to the language?

Hi All,

I want to have adate picker according to the language selected.

Can any one of you help me in doing this.

Regards

DK

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 20, 2006 at 02:52 PM

    Hi DK,

    I Don't think that you can change your Date format to the selected Country format.

    DatePicker will take the format of the browser language Settings.

    I tried using the below code. Still it will take Browser Language Settings.

    String usFormat = "MM/dd/yyyy";
    String ukFormat = "dd/MM/yyyy";
    Date date = wdContext.currentContextElement().getTest2();
    SimpleDateFormat simpD= null;
    int dateOfMonth=date.getDate();
    int month = date.getMonth()+1;
    int year = date.getYear()+1900;
    wdContext.currentContextElement().setTest2(null);
    java.util.Date dt = null;
    String country = wdContext.currentContextElement().getCountry();
    try{
      if(country!= null){
        if(country.equalsIgnoreCase("USA")){
    	simpD = new SimpleDateFormat(usFormat);
    	dt = simpD.parse(month+"/"+dateOfMonth+"/"+year);
        }else if(country.equalsIgnoreCase("UK")){
    	simpD = new SimpleDateFormat(ukFormat);
    	dt = simpD.parse(dateOfMonth+"/"+month+"/"+year);
        }
        wdContext.currentContextElement().setTest2(new Date(dt.getTime()));
      }
    }catch(Exception ee){
    manager.reportSuccess("Exception : "+ee.getMessage());
    }
    

    For more information go thru the link.

    date-format

    Regards,

    Sridhar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 21, 2006 at 05:26 PM

    What do you mean wit "the language selected"? The date picker should always come up in the session locale, if not it's a bug.

    Armin

    Add comment
    10|10000 characters needed characters exceeded