149 |
|
* @param sourceDuration the time duration in the given {@code sourceUnit} |
150 |
|
* @param sourceUnit the unit of the {@code sourceDuration} argument |
151 |
|
* @return the converted duration in this unit, |
152 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
153 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
152 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
153 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
154 |
|
*/ |
155 |
|
public long convert(long sourceDuration, TimeUnit sourceUnit) { |
156 |
|
switch (this) { |
167 |
|
* {@link #convert(long, TimeUnit) NANOSECONDS.convert(duration, this)}. |
168 |
|
* @param duration the duration |
169 |
|
* @return the converted duration, |
170 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
171 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
170 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
171 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
172 |
|
*/ |
173 |
|
public long toNanos(long duration) { |
174 |
|
long s, m; |
187 |
|
* {@link #convert(long, TimeUnit) MICROSECONDS.convert(duration, this)}. |
188 |
|
* @param duration the duration |
189 |
|
* @return the converted duration, |
190 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
191 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
190 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
191 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
192 |
|
*/ |
193 |
|
public long toMicros(long duration) { |
194 |
|
long s, m; |
209 |
|
* {@link #convert(long, TimeUnit) MILLISECONDS.convert(duration, this)}. |
210 |
|
* @param duration the duration |
211 |
|
* @return the converted duration, |
212 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
213 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
212 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
213 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
214 |
|
*/ |
215 |
|
public long toMillis(long duration) { |
216 |
|
long s, m; |
231 |
|
* {@link #convert(long, TimeUnit) SECONDS.convert(duration, this)}. |
232 |
|
* @param duration the duration |
233 |
|
* @return the converted duration, |
234 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
235 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
234 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
235 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
236 |
|
*/ |
237 |
|
public long toSeconds(long duration) { |
238 |
|
long s, m; |
253 |
|
* {@link #convert(long, TimeUnit) MINUTES.convert(duration, this)}. |
254 |
|
* @param duration the duration |
255 |
|
* @return the converted duration, |
256 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
257 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
256 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
257 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
258 |
|
* @since 1.6 |
259 |
|
*/ |
260 |
|
public long toMinutes(long duration) { |
266 |
|
* {@link #convert(long, TimeUnit) HOURS.convert(duration, this)}. |
267 |
|
* @param duration the duration |
268 |
|
* @return the converted duration, |
269 |
< |
* or {@code Long.MIN_VALUE} if conversion would negatively |
270 |
< |
* overflow, or {@code Long.MAX_VALUE} if it would positively overflow. |
269 |
> |
* or {@code Long.MIN_VALUE} if conversion would negatively overflow, |
270 |
> |
* or {@code Long.MAX_VALUE} if it would positively overflow. |
271 |
|
* @since 1.6 |
272 |
|
*/ |
273 |
|
public long toHours(long duration) { |