public static synchronized String timeToString(long time, Resolution resolution) {
    calInstance.setTimeInMillis(round(time, resolution));
    Date date = calInstance.getTime();
    
    if (resolution == Resolution.YEAR) {
      return YEAR_FORMAT.format(date);
    } else if (resolution == Resolution.MONTH) {
      return MONTH_FORMAT.format(date);
    } else if (resolution == Resolution.DAY) {
      return DAY_FORMAT.format(date);
    } else if (resolution == Resolution.HOUR) {
      return HOUR_FORMAT.format(date);
    } else if (resolution == Resolution.MINUTE) {
      return MINUTE_FORMAT.format(date);
    } else if (resolution == Resolution.SECOND) {
      return SECOND_FORMAT.format(date);
    } else if (resolution == Resolution.MILLISECOND) {
      return MILLISECOND_FORMAT.format(date);
    }
    
    throw new IllegalArgumentException("unknown resolution " + resolution);
  }