Add java.time.Duration-based APIs

Open
#776 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start by inventorying the library APIs that accept numeric primitives representing date/time concepts, using the issue's readTimeout example as a reference. Determine which can receive java.time.Duration overloads and how returned numeric values would need alternative names. Done means the affected APIs have a consistent, documented approach without leaving the scope ambiguous.

Written by the indexing model from the issue text.

Description

semver: minor status: blocked type: cleanup

Representing date/time concepts as numeric primitives is a bad idea. It leads to unit mismatch, overflows, and many other dangerous date/time-related bugs.

For instance, it's impossible to tell what time unit readTimeout is without reading it's javadocs:

public final class HttpRequest {
  public HttpRequest setReadTimeout(int readTimeout) { ... }
}

Please consider adding java.time.Duration overloads to all APIs that accept a date/time concept as a numeric primitive. Methods that return a numeric primitive representing a date/time concept are much more difficult as new, alternative method names must be chosen (e.g., public int getReadTimeout()).

Dominant language
Java
Stars
1.4k
Forks
476
Avg merge
10h 47m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleapis/google-http-java-client

All issues in googleapis/google-http-java-client

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.