Mr.J4mes
Mr.J4mes

Reputation: 9266

Is there a library for displaying Timezone in a selectOneMenu

Currently, in my application, I use the following snippet to instantiate a timezone list for displaying in a selectOneMenu:

@Named
@ApplicationScoped
public class MrBean {
    private String[] timezoneIDs;

    @PostConstruct
    public void init() {
        this.timezoneIDs = TimeZone.getAvailableIDs();
    }
}

The good thing that I need & get from this list is the Olson timezone ID that I can easily use with the Joda-Time library. However, the list is very long, which consists of all the available Timezones there are in Java. In short, it's not user-friendly.

enter image description here

In the beginning, I'd like to display a list of GMT timezones but I have no idea, for instance, what the corresponding Olson Timezone ID for GMT+3 is. As a consequence, I couldn't come up with a list of selectItems for the selectOneMenu. That's the reason why I had to use TimeZone.getAvailableIDs();.

I'd be very grateful if you could suggest a library that can help me populate the Timezone list with GMT labels and Olson Timezone ID values.

Upvotes: 0

Views: 1295

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241603

You may find this article of interest.

In short - the best time zone picker is none at all. But second to that are map-based pickers.

My favorite time zone picker for JavaScript is this one.

I don't know if there is anything similar for Java or not. A quick search turned up nothing. If anyone knows of a good map-based time zone picker control/widget for Java, please post a link. Thanks.

Upvotes: 1

Related Questions