Retrieve an Duration instance. Use shared objects to
represent common values for memory efficiency.

@param duration duration value
@param type duration type
@return Duration instance
187981
public static Duration getInstance(double duration, TimeUnit type)
   {
      Duration result;
      if (duration == 0)
      {
         result = ZERO_DURATIONS[type.getValue()];
      }
      else
      {
         result = new Duration(duration, type);
      }
      return (result);
   }
1180981
public void setDuration(Duration duration, Related related) {
		this.date = null;
		this.duration = duration;
		setRelated(related);
	}
1077486
public Long getCount(String type) {
		MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
		params.putSingle(Config._TYPE, type);
		Pager pager = new Pager();
		getItems(find("count", params), pager);
		return pager.getCount();
	}
112910
public static final TimeUnit getDurationTimeUnits(int type)
   {
      TimeUnit units;

      switch (type & DURATION_UNITS_MASK)
      {
         case 3:
         {
            units = TimeUnit.MINUTES;
            break;
         }

         case 4:
         {
            units = TimeUnit.ELAPSED_MINUTES;
            break;
         }

         case 5:
         {
            units = TimeUnit.HOURS;
            break;
         }

         case 6:
         {
            units = TimeUnit.ELAPSED_HOURS;
            break;
         }

         case 8:
         {
            units = TimeUnit.ELAPSED_DAYS;
            break;
         }

         case 9:
         {
            units = TimeUnit.WEEKS;
            break;
         }

         case 10:
         {
            units = TimeUnit.ELAPSED_WEEKS;
            break;
         }

         case 11:
         {
            units = TimeUnit.MONTHS;
            break;
         }

         case 12:
         {
            units = TimeUnit.ELAPSED_MONTHS;
            break;
         }

         default:
         case 7:
         {
            units = TimeUnit.DAYS;
            break;
         }
      }

      return (units);
   }
1149156
public boolean isSupported(DurationFieldType type) {
        if (type == null) {
            return false;
        }
        return type.getField(getChronology()).isSupported();
    }
1372283
public static long getTimeSpan(Date begin, Date end, int type) {
        long diff = end.getTime() - begin.getTime();
        switch (type) {
            case DAY:
            default:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_DAY;
            case HOUR:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_HOUR;
            case MINUTE:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_MINUTE;
            case SECOND:
                return diff / org.apache.commons.lang.time.DateUtils.MILLIS_PER_SECOND;
        }
    }
687174
public com.google.protobuf.Duration getMinPendingLatency() {
    return minPendingLatency_ == null ? com.google.protobuf.Duration.getDefaultInstance() : minPendingLatency_;
  }
1373001
public Long getTypeFirstWaitMs(ResourceType type) {
    synchronized(typeToFirstWait) {
      // Was it ever requested?
      if (!typeToFirstWait.containsKey(type)) {
        return null;
      }
      Long firstWait = typeToFirstWait.get(type);
      if (firstWait == null) {
        return ClusterManager.clock.getTime() - startTime;
      }

      return firstWait;
    }
  }
176923
@SuppressWarnings("unchecked")
    public <A extends Comparable<?>> TimePath<A> getTime(String property, Class<A> type) {
        Class<? extends A> vtype = validate(property, type);
        return super.createTime(property, (Class<? super A>) vtype);
    }
1137545
public TimeDuration plus(TimeDuration duration) {
        return createWithCarry(sec + duration.getSec(), nanoSec + duration.getNanoSec());
    }
803435
def duration(self, value):
        

        if value is not None:
            assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format("duration", value)
            assert value >= 0, "'{0}' attribute: '{1}' need to be exactly positive!".format("duration", value)
        self.__duration = value
392860
public static final BigInteger printDurationTimeUnits(Duration duration, boolean estimated)
   {
      // SF-329: null default required to keep Powerproject happy when importing MSPDI files
      TimeUnit units = duration == null ? PARENT_FILE.get().getProjectProperties().getDefaultDurationUnits() : duration.getUnits();
      return printDurationTimeUnits(units, estimated);
   }
662283
public static String durationToFormattedString(final Duration duration) {
        if (duration == null) {
            return null;
        }

        return LocalTime.ofNanoOfDay(duration.toNanos()).format(DateTimeFormatter.ofPattern(DURATION_FORMAT));
    }
744772
public Duration subtract( Duration duration ) {
        return new Duration(this.durationInNanos - (duration == null ? 0l : duration.longValue()));
    }
1092075
public static DayDuration valueOf(String duration) {
		int spacePos = duration.indexOf(' ');
		if(spacePos == -1) throw new IllegalArgumentException("Space not found in duration: " + duration);
		return getInstance(
			Integer.parseInt(duration.substring(0, spacePos)),
			Unit.valueOfUnit(duration.substring(spacePos + 1))
		);
	}
281811
public static ContentType getInstance(String type)
    {
        if(type.equals(TEST.toString()))
        {
            return TEST;
        }
        else if(type.equals(REQUIREMENT.toString()))
        {
            return REQUIREMENT;
        }
        else if(type.equals(BOTH.toString()))
        {
            return BOTH;
        }

        return UNKNOWN;
    }
112468
public static final BigInteger printDurationInIntegerTenthsOfMinutes(Duration duration)
   {
      BigInteger result = null;

      if (duration != null && duration.getDuration() != 0)
      {
         result = BigInteger.valueOf((long) printDurationFractionsOfMinutes(duration, 10));
      }

      return result;
   }