Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Confusing documentation for com.google.cloud.Timestamp.parseTimestamp #254

@sebright2

Description

@sebright2

The Javadoc for com.google.cloud.Timestamp.parseTimestamp says that the input doesn't have a timezone offset and ends with "Z":

/**
* Creates a Timestamp instance from the given string. String is in the RFC 3339 format without
* the timezone offset (always ends in "Z").
*/
public static Timestamp parseTimestamp(String timestamp) {

However, it seems to parse offsets correctly with google-cloud-core 1.93.7:

import com.google.cloud.Timestamp;
import org.junit.Test;

public class TimestampTest {

  @Test
  public void parseTimestamp() {
    System.err.println(Timestamp.parseTimestamp("2020-07-10T14:03:00-07:00"));
    System.err.println(Timestamp.parseTimestamp("2020-07-10T14:03:00Z"));
  }
}
2020-07-10T21:03:00Z
2020-07-10T14:03:00Z

I would expect either of the following:

  1. parseTimestamp handles a timezone offset, and the documentation doesn't specify that there is no offset.
  2. parseTimestamp doesn't handle a timezone offset and throws an exception when one is present.

This issue may be related to googleapis/google-cloud-java#4583. The fix changed the parsing logic but not the documentation.

Metadata

Metadata

Assignees

Labels

type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions