title: How to format date in MM/DD/YYYY in Delphi
body: <p>I have array of string as mentioned below.</p>
  
  <pre><code>Param : array[1..5] of string = ('US','Dollor','27/03/2017','IND','INR');
  </code></pre>
  
  <p>I need to find the string which contains date and format it in MM/DD/YYYY.
  To achieve this I am running for loop and passing each string in TryStrToDate. If string is of date type, it will return true and then I will format that string in desired format. My code is as below</p>
  
  <pre><code> for i := 1 to ParamCount do
    begin
     if TryStrToDate(Param[i],DateValue)=true then
     begin
      Param[i] := DateToStr(StrToDate(Param[i]));
      ShowMessage(Param[i]);
     end;
   end;
  </code></pre>
  
  <p>Here date in Param[] is in DD/MM/YYYY so TryStrToDate is unable to understand. How can i change the code?
  After this final result should be as below</p>
  
  <pre><code>Param : array[1..5] of string = ('US','Dollor','03/27/2017','IND','INR');
  </code></pre>
  
  <p><strong>Used Mark's solution as below:</strong></p>
  
  <pre><code>  GetLocaleFormatSettings(ALocID, AFormatSettings);
    AFormatSettings.ShortDateFormat := 'DD/MM/YYYY';
    for i := 1 to ParamCount do
    begin
      if TryStrToDate(param[i], DateValue, AFormatSettings) = False then
        Continue;
      try
        DateVal := StrToDate(param[i], AFormatSettings);
        param[i] := DateToStr(DateVal);
        Continue;
      except
        Continue;
      end;
    end;
  </code></pre>