Example usage for org.joda.time DateTimeZone getName

List of usage examples for org.joda.time DateTimeZone getName

Introduction

In this page you can find the example usage for org.joda.time DateTimeZone getName.

Prototype

public final String getName(long instant) 

Source Link

Document

Gets the long name of this datetime zone suitable for display using the default locale.

Usage

From source file:org.thelq.pircbotx.commands.NewYearsCommand.java

License:Open Source License

protected static String getExtendedNames(Collection<DateTimeZone> tzList) {
    if (tzList.isEmpty())
        return null;
    //Prebuild long form of timezones
    long nowTime = System.currentTimeMillis();
    Set<String> tzExtendedSet = Sets.newHashSet();
    for (DateTimeZone curTz : tzList) {
        if (StringUtils.startsWithIgnoreCase(curTz.getID(), "Etc/"))
            continue;
        tzExtendedSet.add(curTz.getName(nowTime) + "(" + curTz.getShortName(nowTime) + ")");
    }//  w ww  .j  a va  2  s . c o m
    return StringUtils.defaultIfBlank(StringUtils.join(tzExtendedSet, ", "), null);
}

From source file:org.unitime.timetable.server.ServerTimeZoneBackend.java

License:Open Source License

@Override
public ServerTimeZoneResponse execute(ServerTimeZoneRequest request, SessionContext context) {
    Date first = null, last = null;
    for (Session session : SessionDAO.getInstance().findAll()) {
        if (first == null || first.after(session.getEventBeginDate()))
            first = session.getEventBeginDate();
        if (last == null || last.before(session.getEventEndDate()))
            last = session.getEventEndDate();
    }/*  w ww .j a  va 2  s . c o  m*/
    DateTimeZone zone = DateTimeZone.getDefault();
    int offsetInMinutes = zone.getOffset(first.getTime()) / 60000;
    ServerTimeZoneResponse ret = new ServerTimeZoneResponse();
    ret.setId(zone.getID());
    ret.addName(zone.getName(new Date().getTime()));
    ret.setTimeZoneOffsetInMinutes(offsetInMinutes);
    long time = first.getTime();
    long transition;
    while (time != (transition = zone.nextTransition(time)) && time < last.getTime()) {
        int adjustment = (zone.getOffset(transition) / 60000) - offsetInMinutes;
        ret.addTransition((int) (transition / 3600000), adjustment);
        time = transition;
    }
    return ret;
}