cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a date picker according to the language?

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

sridhar_k2
Active Contributor
0 Kudos

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.

Regards,

Sridhar

Answers (1)

Answers (1)

Former Member
0 Kudos

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

sridhar_k2
Active Contributor
0 Kudos

Hi,

language selected - Means Browser Language. I agree with you Armin.

Regards,

Sridhar