ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/TimeUnit.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/TimeUnit.java (file contents):
Revision 1.31 by dl, Tue Jun 14 15:09:34 2005 UTC vs.
Revision 1.32 by dl, Sat Jun 18 12:03:05 2005 UTC

# Line 151 | Line 151 | public enum TimeUnit {
151          return d * m;
152      }
153  
154 +    // To maintain full signature compatibility with 1.5, method
155 +    // convert etc are not declared abstract but otherwise act as
156 +    // abstract methods.
157 +
158      /**
159       * Convert the given time duration in the given unit to this
160       * unit.  Conversions from finer to coarser granularities
# Line 160 | Line 164 | public enum TimeUnit {
164       * with arguments that would numerically overflow saturate to
165       * <tt>Long.MIN_VALUE</tt> if negative or <tt>Long.MAX_VALUE</tt>
166       * if positive.
167 +     * <p>
168 +     * For example, to convert 10 minutes to milliseconds, use:
169 +     * <tt>TimeUnit.MILLISECONDS.convert(10L, TimeUnit.MINUTES)</tt>
170       *
171 <     * @param duration the time duration in the given <tt>unit</tt>
172 <     * @param unit the unit of the <tt>duration</tt> argument
171 >     * @param sourceDuration the time duration in the given <tt>unit</tt>
172 >     * @param sourceUnit the unit of the <tt>sourceDuration</tt> argument
173       * @return the converted duration in this unit,
174       * or <tt>Long.MIN_VALUE</tt> if conversion would negatively
175       * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
176       */
177 <    public abstract long convert(long duration, TimeUnit unit);
177 >    public long convert(long sourceDuration, TimeUnit sourceUnit) {
178 >        throw new AbstractMethodError();
179 >    }
180  
181      /**
182       * Equivalent to <tt>NANOSECONDS.convert(duration, this)</tt>.
# Line 177 | Line 186 | public enum TimeUnit {
186       * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
187       * @see #convert
188       */
189 <    public abstract long toNanos(long duration);
189 >    public long toNanos(long duration) {
190 >        throw new AbstractMethodError();
191 >    }
192  
193      /**
194       * Equivalent to <tt>MICROSECONDS.convert(duration, this)</tt>.
# Line 187 | Line 198 | public enum TimeUnit {
198       * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
199       * @see #convert
200       */
201 <    public abstract long toMicros(long duration);
201 >    public long toMicros(long duration) {
202 >        throw new AbstractMethodError();
203 >    }
204  
205      /**
206       * Equivalent to <tt>MILLISECONDS.convert(duration, this)</tt>.
# Line 197 | Line 210 | public enum TimeUnit {
210       * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
211       * @see #convert
212       */
213 <    public abstract long toMillis(long duration);
213 >    public long toMillis(long duration) {
214 >        throw new AbstractMethodError();
215 >    }
216  
217      /**
218       * Equivalent to <tt>SECONDS.convert(duration, this)</tt>.
# Line 207 | Line 222 | public enum TimeUnit {
222       * overflow, or <tt>Long.MAX_VALUE</tt> if it would positively overflow.
223       * @see #convert
224       */
225 <    public abstract long toSeconds(long duration);
225 >    public long toSeconds(long duration) {
226 >        throw new AbstractMethodError();
227 >    }
228  
229      /**
230       * Equivalent to <tt>MINUTES.convert(duration, this)</tt>.
# Line 218 | Line 235 | public enum TimeUnit {
235       * @see #convert
236       * @since 1.6
237       */
238 <    public abstract long toMinutes(long duration);
238 >    public long toMinutes(long duration) {
239 >        throw new AbstractMethodError();
240 >    }
241  
242      /**
243       * Equivalent to <tt>HOURS.convert(duration, this)</tt>.
# Line 229 | Line 248 | public enum TimeUnit {
248       * @see #convert
249       * @since 1.6
250       */
251 <    public abstract long toHours(long duration);
251 >    public long toHours(long duration) {
252 >        throw new AbstractMethodError();
253 >    }
254  
255      /**
256       * Equivalent to <tt>DAYS.convert(duration, this)</tt>.
# Line 238 | Line 259 | public enum TimeUnit {
259       * @see #convert
260       * @since 1.6
261       */
262 <    public abstract long toDays(long duration);
262 >    public long toDays(long duration) {
263 >        throw new AbstractMethodError();
264 >    }
265  
266      /**
267       * Utility to compute the excess-nanosecond argument to wait,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines