### Localize Date Format

A possible way to get a localized date format, is using Inline Java.
'Get a localized date
'Parameter: Date as Long
'Parameter: Locale as string, like nl, uk, us etc.
'Example B4J:
'Global Private joInline As JavaObject = Me
'Log("Date Localized NL = " & joInline.RunMethod("getDateLocalized", Array(DateTime.Now, "nl")))
'Log("Date Localized US = " & joInline.RunMethod("getDateLocalized", Array(DateTime.Now, "us")))
If JAVA
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public static String getDateLocalized(long mdate, String mlocale) {
int style = DateFormat.MEDIUM; //Other Dateformat styles: FULL, SHORT
DateFormat df=null;
df = DateFormat.getDateInstance(style, new Locale(mlocale));
return df.format(mdate);
}
End If
Use Locale.COUNTRY instead of new Locale
Replace
df = DateFormat.getDateInstance(style, new Locale(mlocale));
By example
df = DateFormat.getDateInstance(style, Locale.UK);
df = DateFormat.getDateInstance(style, Locale.US);
List of available Locales
'Get the list of avialable locales
'Returns a list holding the locals with information Language, Country, Variant, Name
'Example B4J:
'Globals
'Private joInline As JavaObject = Me
'Private lvwLocales As ListView
'Run Methods
'Populate a listview with list of available locales
'lvwLocales.Items.AddAll(joInline.RunMethod("getLocales", Null))
'lvwLocales.Items.Sort(True)
If JAVA
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.*;
public static List

Changed: , Category: DateTime, File: T6C183M1330.htm, ID: 1330