Wednesday 12 October 2011

How to use custom DatePicker Using Salesforce Js for all Locales

Hi Friends today I came with a custom datepicker which can be used in visualforce Page.By using this we don't need to use any Jquery or static resource. I faced this problem and got this code from some where Please Click Here
to go to that place. but this DatePicker was only for specific USA locale. I made small changes for using in my Vf page Final VF-code is as follows:-
  



    
    
    




    Date Lookup
    
    
    
    
    
    
    




 {!TODAY()} ]
 
Previous Month Next Month
SunMonTueWedThuFriSat


So I made it useful for those whose user has different Locale also creating it's controller as follows:-
Controller-code:-
  
public class datePickercontroller {
public date converedDate{get;private set;}
public string selectedDate{get;
    set
    {   if(value!=null || value != ''){
            Integer month_num = Integer.valueOf(value.subString(0,value.indexOf('/', 0)));
            Integer date_num = Integer.valueOf(value.subString(value.indexOf('/', 0)+1,value.indexOf('/',value.indexOf('/', 0)+1 ))); 
            Integer year_num = Integer.valueOf(value.subString(value.indexOf('/', 0)+value.indexOf('/',value.indexOf('/', 0)+1 ),value.length()));
            converedDate = date.newinstance(year_num , month_num ,date_num );
        }
    }
}
}
I think this way would be useful for you.
Credit for this DatePicker should goes to it's developer I got this Code form this link click Here
with regards...

No comments:

Post a Comment