com.microsoft.azure.documentdb.DocumentClientException 日期 header 不符合要求的格式

com.microsoft.azure.documentdb.DocumentClientException Date header doesn't conform to the required format

我正在使用 SQL Api 开发 Azure Cosmos DB。我正在使用来自:

的 Azure SDK
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-documentdb</artifactId>
    <version>2.4.7</version>
</dependency>

以便将项目插入 collection。

  DocumentClient documentClient = setupDocumentClient();
  ResourceResponse<Document> document = documentClient.createDocument("/dbs/" + databaseName + "/colls/" + colName, entity, new RequestOptions(), true);

我遇到异常:

com.microsoft.azure.documentdb.DocumentClientException: Message: {"Errors":["Date header doesn't conform to the required format. Please ensure that the time is provided in GMT and conforms to RFC 1123 date-time specifications.","Date header doesn't conform to the required format. Please ensure that the time is provided in GMT and conforms to RFC 1123 date-time specifications."]}

奇怪的是,我在另一个项目中使用了相同的代码,并且没有出现此异常,并且数据已正确插入到 Azure Cosmos DB 中。也许有人遇到过这个问题并找到了解决方案?

我已在我的代码中通过添加解决了这个问题:

<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>LATEST</version>
</dependency>

之后我 运行 mvn clean install 并且异常消失了。

显然我项目的其他依赖项之一是指 joda-time.

的旧依赖项