Jump to content

How to change default day language in timestamp?


lukmanars

Recommended Posts

 i have a problem like this, 
i make a text Field :
$F(date_in)
Expression Class = java.util.date
Pattern = EEEE dd MMMMM yyyy

if i run my report, it should be like : Tuesday, 02 augustus 2011

the problem is my boss want to display date in Indonesian language,
it must be like : Selasa, 02 Agustus 2011

Sunday  --> Minggu
Monday --> Senin
Tuesday --> Selasa
Wednesday --> Rabu
Thursday --> kamis
Friday --> Jumat
saturday --> Sabtu

the problem is i dont know how to convert that default day into indonesia language,,
anyone know how to resolve this problem??  
:(

Thanks,, 
Lukman

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Lukman,

You are thinking of this problem the wrong way. Formatting the data to an English-language day of the week and then converting that manually to Indonesian is possible... but there's no reason to do it. Let Java do it for you:

 

DateFormatUtils.format($P{MyDate},"EEEE, dd MMMMM yyyy",new java.util.Locale("id"))

In fact... for this there's no reason you need Commons Lang. If you are already using it, then that's fine. But you could do the same thing like this:

new SimpleDateFormat("EEEE, dd MMMMM yyyy",new java.util.Locale("id")).format($P{MyDate})

When I run the above code (either one of them) with today's date I get this:

Rabu, 03 Agustus 2011

Regards,
Matt

P.S. I guess that it would be better to create a Parameter with a default value of "new java.util.Locale("id")". Then use this param rather than creating a new Locale object everytime. But I'm not reallly a Java developer, so I'm not too sure.

 

 

Link to comment
Share on other sites

whoa..
thank you very much Matt.
your answer is very helpful  /tools/fckeditor/editor/images/smiley/msn/thumbs_up.gif

the first i use code :
 new SimpleDateFormat("EEEE, dd MMMMM yyyy",new java.util.Locale("id")).format(F${TGL_IN})
with Expression Class is "java.util.Date"

i got error : 
Cannot cast object 'Kamis, 16 Juni 2011' with class 'java.lang.String' to class 'java.util.Date' 

after that i change the expression class to "java.lang.String"
Because i think that code like to_char()  in SQL, that convert Date, into String and change the language..

and than it can show, the result is "Kamis, 16 Juni 2011"

once again, i want to say, thank you very much Matt..  ^_^


Regards,
Lukman

 

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...