:: My another contributions in Delphi

»Delphi3000.com
posting and uploading delphi articles
[currently as Top 66 uploader]


»Komunitas Delphi Indonesia
starting as a member

Saturday, November 25, 2006

:: Displaying Month Names in Indonesian or Other Language Using FormatDateTime Function

» FormatDateTime Function

Category:

» DateTime & System

Question/Problem/Abstract:
» How we can display long month names in a specific language, eg Indonesia
So, the result will be like this : today is 25 Nopember 2006

Answer:

Actually, that's quiet simple to do that
You only need to replace the default (Delphi) "LongMonthNames" constants with the preferable any language you desire.

For this example, I want to display a specific date into Indonesian Date Format (dd MMMM yyyy)

Which,
» January is Januari in Indonesian
» February is Februari
» March is Maret
» April is April
» May is Mei
» June is Juni
» July is Juli
» August is Agustus
» September is September (unchanged)
» October is Oktober
» November is Nopember
» December is Desember

The example code would be like this :
-------------------------------------

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;

type
TForm1 = class(TForm)
DateTimePicker1: TDateTimePicker;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

// English:
// this variable ("namaBulan") is used to replace month names' string
// from English into Indonesian
// this variable is used in "replaceLongMonthNamesWithIndonesian" procedure

// dipakai untuk menggantikan string nama bulan dr bhs Inggris ke Indonesia
// digunakan dalam procedure "replaceLongMonthNamesWithIndonesian"
namaBulan: array[1..12] of string =
( 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli',
'Agustus', 'September', 'Oktober', 'Nopember', 'Desember');

// You can change the string constant above with your language choice

implementation

{$R *.dfm}

procedure replaceLongMonthNamesWithIndonesian;
var i : integer;
begin
for i:=1 to High(namaBulan) do
LongMonthNames[i] := namaBulan[i];
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
replaceLongMonthNamesWithIndonesian;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessageFmt(
'The date in Indonesian format (dd mmmm yyyy) : %s',
[FormatDateTime('dd MMMM yyyy', DateTimePicker1.Date)]);
end;

end.

-------------------------------------
// end of the code

if you want to change the short name of a month with some other language either, you need to change the "ShortMonthNames" like we did above


Enjoy it

ps : the original code is posted @delphi3000.com [http://www.delphi3000.com/articles/article_4642.asp] by me either


28 comments:

Anonymous said...

Thanks for ones marvelous posting! I quite enjoyed
reading it, you happen to be a great author. I will be sure to bookmark your blog
and definitely will come back someday. I want to encourage one
to continue your great job, have a nice morning!


Also visit my blog post More information

Anonymous said...

Good day! I could have sworn I've been to this blog before but after browsing through some of the post I realized it's new to
me. Nonetheless, I'm definitely delighted I found it and I'll be book-marking and checking
back frequently!

Feel free to surf to my web page :: visit link

Anonymous said...

Way cool! Some extremely valid points! I appreciate you writing this
write-up plus the rest of the website is really good.

My web page; site

Anonymous said...

Thank you for the good writeup. It in fact was a amusement account it.
Look advanced to more added agreeable from you!
However, how could we communicate?

Here is my web blog - corporate training Western Cape

Anonymous said...

Your style is very unique compared to other people I've read stuff from. Thank you for posting when you've got the opportunity, Guess I will just book mark this web
site.

Feel free to visit my web page backrest Cape Town

Anonymous said...

I am regular reader, how are you everybody?
This piece of writing posted at this site is genuinely fastidious.


my homepage ... Know more

Anonymous said...

Hmm is anyone else experiencing problems with the images on this blog loading?
I'm trying to determine if its a problem on my end or if it's the blog.
Any feedback would be greatly appreciated.

Here is my web page: more info

Anonymous said...

If you desire to take a great deal from this post then you have to apply such techniques to your won webpage.


Here is my web blog more information

Anonymous said...

I like the helpful info you supply for your articles. I'll bookmark your weblog and take a look at once more here regularly. I'm relatively certain I'll be informed many new stuff proper here! Best of luck for the next!

my webpage more info

Anonymous said...

I think this is one of the most significant information for me.

And i'm glad reading your article. But want to remark on some general things, The website style is ideal, the articles is really great : D. Good job, cheers

My web-site; site

Anonymous said...

Really when someone doesn't understand after that its up to other visitors that they will help, so here it occurs.

my homepage :: event equipment hire gauteng

Anonymous said...

Post writing is also a excitement, if you know after that you can write if not it
is complicated to write.

my blog post: piercings Port Elizabeth

Anonymous said...

Incredible points. Great arguments. Keep up the amazing
effort.

Also visit my site; servicing Of garage doors sandton

Anonymous said...

You really make it seem really easy together with your presentation however I find this matter to be really something that I feel I would never understand.
It seems too complicated and extremely large for me.
I'm taking a look ahead to your subsequent publish, I will attempt to get the grasp of it!

Also visit my site :: auto parts Malta

Anonymous said...

This blog was... how do you say it? Relevant!! Finally I have found something that helped me.
Thanks!

Here is my page :: domestic cleaners Midrand

Anonymous said...

These are truly enormous ideas in on the topic of blogging.

You have touched some pleasant points here. Any way keep up wrinting.


my web blog; wooden flooring Overberg

Anonymous said...

What's up mates, good post and fastidious urging commented at this place, I am truly enjoying by these.

my web page boat builders Cape Town

Anonymous said...

Hi friends, fastidious piece of writing and pleasant arguments commented here, I
am really enjoying by these.

Also visit my blog software consultant Gauteng

Anonymous said...

Thanks for sharing your thoughts on maryland science center.
Regards

my homepage ... interior design and architecture

Anonymous said...

Greetings! I've been reading your web site for some time now and finally got the bravery to go ahead and give you a shout out from Atascocita Tx! Just wanted to mention keep up the excellent work!

my web blog: touch screens south africa

Anonymous said...

We're a group of volunteers and starting a new scheme in our community. Your web site offered us with valuable information to work on. You've
done an impressive job and our entire community will
be grateful to you.

Visit my blog ... cupcakes

Anonymous said...

I’m not that much of a online reader to be
honest but your sites really nice, keep it up!
I'll go ahead and bookmark your site to come back in the future. Cheers

Also visit my webpage; bookkeeping around durban

Anonymous said...

Hello! I just wanted to ask if you ever have any issues with hackers?

My last blog (wordpress) was hacked and I ended up losing months of hard work due to no data backup.
Do you have any methods to prevent hackers?

my weblog shop front signs western cape

Anonymous said...

Fantastic web site. Plenty of helpful information here.
I am sending it to a few friends ans additionally sharing in delicious.
And of course, thanks on your effort!

Feel free to surf to my web-site :: general building & construction

Anonymous said...

Wow, this article is pleasant, my sister is analyzing these things,
thus I am going to convey her.

Have a look at my website: brand management

Anonymous said...

If some one needs expert view concerning running a blog after that i propose him/her to pay a quick visit
this webpage, Keep up the fastidious work.

Also visit my weblog :: click here

Anonymous said...

I don't comment, but I looked at a few of the comments on ":: Displaying Month Names in Indonesian or Other Language Using FormatDateTime Function". I actually do have 2 questions for you if it's
allright. Could it be only me or do some of these
comments come across like they are left by brain dead
visitors? :-P And, if you are writing at other online social sites, I'd like to keep up with anything new you have to post. Could you post a list of the complete urls of all your shared sites like your linkedin profile, Facebook page or twitter feed?

Visit my web page :: Boarding Kennels

Anonymous said...

e cigarette, electronic cigarettes, e cigarette reviews, e cigarette, electronic cigarette reviews, electronic cigarette starter kit