본문 바로가기
Delphi/프로시저-함수

TFormatSettings를 사용한 지역화된 숫자/날짜 포맷 처리

by MonoSoft 2025. 4. 7.
728x90
반응형

TFormatSettings를 사용한 지역화된 숫자/날짜 포맷 처리

 

델파이에서 숫자나 날짜 형식을 지역 설정에 따라 
다르게 출력해야 할 경우 TFormatSettings를 사용하면 유용합니다. 
특히 다국어 지원이나 사용자 맞춤 포맷이 필요할 때 매우 효과적입니다.

uses
  System.SysUtils;

procedure ShowLocalizedDateAndNumber;
var
  FS: TFormatSettings;
  FormattedDate, FormattedNumber: string;
begin
  FS := TFormatSettings.Create('fr-FR');  // 프랑스 지역 설정

  FormattedDate := FormatDateTime('dd mmmm yyyy', Date, FS);
  FormattedNumber := FormatFloat('#,##0.00', 1234567.89, FS);

  ShowMessage('날짜 (프랑스): ' + FormattedDate);         // 예: "07 avril 2025"
  ShowMessage('숫자 (프랑스): ' + FormattedNumber);       // 예: "1 234 567,89"
end;


● TFormatSettings.Create('언어코드')로 국가별 설정 적용 가능
● 날짜, 시간, 소수점, 천 단위 구분자 등 지역 맞춤 포맷 적용
● FormatDateTime, FormatFloat, Format 등과 함께 사용

 



728x90
반응형

댓글