Java Code Examples for org.joda.time.DateTimeZone#getID()

The following examples show how to use org.joda.time.DateTimeZone#getID() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ISOChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a debugging toString.
 * 
 * @return a debugging string
 */
public String toString() {
    String str = "ISOChronology";
    DateTimeZone zone = getZone();
    if (zone != null) {
        str = str + '[' + zone.getID() + ']';
    }
    return str;
}
 
Example 2
Source File: ZonedChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param localInstant  the instant from 1970-01-01T00:00:00 local time
 * @return the instant from 1970-01-01T00:00:00Z
 */
private long localToUTC(long localInstant) {
    DateTimeZone zone = getZone();
    int offset = zone.getOffsetFromLocal(localInstant);
    localInstant -= offset;
    if (offset != zone.getOffset(localInstant)) {
        throw new IllegalInstantException(localInstant, zone.getID());
    }
    return localInstant;
}
 
Example 3
Source File: BuddhistChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a debugging toString.
 * 
 * @return a debugging string
 */
public String toString() {
    String str = "BuddhistChronology";
    DateTimeZone zone = getZone();
    if (zone != null) {
        str = str + '[' + zone.getID() + ']';
    }
    return str;
}
 
Example 4
Source File: ISOChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a debugging toString.
 * 
 * @return a debugging string
 */
public String toString() {
    String str = "ISOChronology";
    DateTimeZone zone = getZone();
    if (zone != null) {
        str = str + '[' + zone.getID() + ']';
    }
    return str;
}
 
Example 5
Source File: ZonedChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param localInstant  the instant from 1970-01-01T00:00:00 local time
 * @return the instant from 1970-01-01T00:00:00Z
 */
private long localToUTC(long localInstant) {
    DateTimeZone zone = getZone();
    int offset = zone.getOffsetFromLocal(localInstant);
    localInstant -= offset;
    if (offset != zone.getOffset(localInstant)) {
        throw new IllegalInstantException(localInstant, zone.getID());
    }
    return localInstant;
}
 
Example 6
Source File: BuddhistChronology.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a debugging toString.
 * 
 * @return a debugging string
 */
public String toString() {
    String str = "BuddhistChronology";
    DateTimeZone zone = getZone();
    if (zone != null) {
        str = str + '[' + zone.getID() + ']';
    }
    return str;
}
 
Example 7
Source File: AcademicChronology.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public String toString() {
    String str = "AcademicChronology";
    DateTimeZone zone = getZone();
    if (zone != null) {
        str = str + '[' + zone.getID() + ']';
    }
    return str;
}
 
Example 8
Source File: ParseTime.java    From h2o-2 with Apache License 2.0 5 votes vote down vote up
public static String listTimezones() {
  DateTimeFormatter offsetFormatter = new DateTimeFormatterBuilder().appendTimeZoneOffset(null, true, 2, 4).toFormatter();
  Set<String> idSet = DateTimeZone.getAvailableIDs();
  Map<String, String> tzMap = new TreeMap();
  Iterator<String>  it = idSet.iterator();
  String id, cid, offset, key, output;
  DateTimeZone tz;
  int i = 0;
  long millis = System.currentTimeMillis();


  // collect canonical and alias IDs into a map
  while (it.hasNext()) {
    id = it.next();
    tz = DateTimeZone.forID(id);
    cid = tz.getID();
    offset = offsetFormatter.withZone(tz).print(tz.getStandardOffset(millis));
    key = offset + " " + cid;
    if (id == cid) { // Canonical ID
      if (!tzMap.containsKey(key)) tzMap.put(key, "");
    }  else {// alias ID
      if (!tzMap.containsKey(key)) tzMap.put(key, id);
      else tzMap.put(key,  tzMap.get(key) + ", " + id);
    }
  }

  // assemble result
  output = "StandardOffset CanonicalID, Aliases\n";
  for (Map.Entry<String, String> e : tzMap.entrySet())
    output += e.getKey() + e.getValue()+"\n";

  return output;
}
 
Example 9
Source File: CachedDateTimeZone.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private CachedDateTimeZone(DateTimeZone zone) {
    super(zone.getID());
    iZone = zone;
}
 
Example 10
Source File: CachedDateTimeZone.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private CachedDateTimeZone(DateTimeZone zone) {
    super(zone.getID());
    iZone = zone;
}
 
Example 11
Source File: DateTimeZoneConverter.java    From gson-jodatime-serialisers with MIT License 2 votes vote down vote up
/**
 * Gson invokes this call-back method during serialization when it encounters a field of the
 * specified type. <p>
 *
 * In the implementation of this call-back method, you should consider invoking
 * {@link JsonSerializationContext#serialize(Object, Type)} method to create JsonElements for any
 * non-trivial field of the {@code src} object. However, you should never invoke it on the
 * {@code src} object itself since that will cause an infinite loop (Gson will call your
 * call-back method again).
 * @param src the object that needs to be converted to Json.
 * @param typeOfSrc the actual type (fully genericized version) of the source object.
 * @return a JsonElement corresponding to the specified object.
 */
@Override
public JsonElement serialize(DateTimeZone src, Type typeOfSrc, JsonSerializationContext context)
{
  return new JsonPrimitive(src.getID());
}