package net.sf.jasperreports.engine.util; import java.util.Locale; import java.util.TimeZone; public class JRDataUtils { public static String getLocaleCode(Locale locale) { return locale.toString(); } public static Locale getLocale(String code) { String language, country, variant; int firstSep = code.indexOf('_'); if (firstSep < 0) { language = code; country = variant = ""; } else { language = code.substring(0, firstSep); int secondSep = code.indexOf('_', firstSep + 1); if (secondSep < 0) { country = code.substring(firstSep + 1); variant = ""; } else { country = code.substring(firstSep + 1, secondSep); variant = code.substring(secondSep + 1); } } return new Locale(language, country, variant); } public static String getTimeZoneId(TimeZone tz) { return tz.getID(); } public static TimeZone getTimeZone(String id) { return TimeZone.getTimeZone(id); } }