DateField in 24 hours format

Hello,
Could you please tell me how to have 24 hour format for the input in DateField. Currently it is only showing in 12 hour format.

Thanks,
Jacob.

Hi,

You can set the locale of the component to something that uses 24h format.

The following code should at least serve the DateField with 24h format


        DateField df = new DateField();

        df.setLocale(new Locale("fi", "FI"));
        df.setResolution(DateField.RESOLUTION_SEC);


http://vaadin.com/book/-/page/components.datefield.html


http://vaadin.com/book/-/page/components.features.html#components.features.locale

Thanks Jonas, I’m using Locale.UK and I get it in 24 hour format.

thanks again for your help
Jacob.

All components have that locale methods and their initial value is taken from the application class. If you have a lot of datefields that you want to have in a specific locale, then I’d suggest to set the locale (Application.setLocale(locale)) in the init method of the application. You’ll save a bunch of df.setLocale() that way and you can specify the whole application’s locale in one place as well.

Here is the extension of Datefield component.
https://vaadin.com/directory#addon/customwidgetset

Usage:
CustomDateField df = new CustomDateField();
df.setbTwelveHourClock(false); //24 hour mode

Hi
I am using datefield component in vaadin. i want 24 hourformat in datefield(Means remove am and pm) from datefiled.
i am able to achieve this one by using changing locale to UK.

DateField df = new DateField(“Date”);
df.setResolution(Resolution.MINUTE);
df.setLocale(Locale.ENGLISH);

but i want to 24 hour format where locale should be Locale.ENGLISH . and without changing the locale.UK.

please help me

Thanks
Santoshkumar.

DateField df = new DateField(“Date”);
df.setLocale(Locale.ENGLISH);

df.setLocale(new Locale(“fi”, “FI”)); // This will solve your problem…

df.setResolution(Resolution.MINUTE);

thank you for reply.

but for using this locale
df.setLocale(new Locale(“fi”, “FI”)

language is changing .

janauary
coming another language like
elokuu
2013. same thing for february,march etc.
i want language should be english.

thanks

Hi
i want 24 hourformat in enlsih.

df.setLocale(new Locale(“en”, “EN”));

when i changed locale to english.
12hourformat is coming.

so i want 24format irrespective of language.

thanks.

Hi all,

I had the same problem and solved it setting as GB (Great Britain) and it works with 24h format

date.setLocale(new Locale(“en”, “GB”));

Hope it helps
Ruben

[size=3]
[color=#000000]
[font=Calibri,Helvetica,sans-serif]
[size=3]
Combining these two works for en US. If we only use the GB locale, the month and day order changes.

dateField.setDateFormat(“MM/dd/yyyy HH:mm:ss”);
[/size]
[/font]
[/color]
[/size]





dateField.setLocale(new Locale(“en”, “GB”));