-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
Despite expecting ISO-8601 string to be stored, the datetime is being stored as number, Applies for types LocalDateTime, Instant and ZonedDateTime and Date
Exception or Stack Trace
No exception thrown
To Reproduce
- Create Model with ZonedDateTime property, using @DateTimeFormat(iso = ISO.DATE_TIME) annotation
- Create Repository
- Set spring boilerplate to create model instance and trigger save method of repository
- Check Cosmos Explorer Items
Model
Code Snippet
import com.azure.spring.data.cosmos.core.mapping.Container;
import com.azure.spring.data.cosmos.core.mapping.PartitionKey;
import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
@Data
@Container(containerName = "FileMetaData")
public class MetaData {
@Id
UUID id;
String safeName;
String displayName;
String mimeType;
FileExtension extension;
@DateTimeFormat(iso = ISO.DATE)
ZonedDateTime createdAt = ZonedDateTime.now();
@PartitionKey
@DateTimeFormat(iso = ISO.DATE_TIME)
ZonedDateTime deletedAt;
}Repository
import com.azure.spring.data.cosmos.repository.CosmosRepository;
import com.azure.spring.data.cosmos.repository.Query;
import java.util.List;
import java.util.UUID;
import org.springframework.stereotype.Repository;
@Repository
public interface MetaDataRepository extends CosmosRepository<MetaData, UUID> { }Expected behavior
Expected date to be stored as an ISO-8601 string
Setup (please complete the following information):
- OS: Windows 10
- IDE: IntelliJ
- Library/Libraries: spring-cloud-azure-starter-data-cosmos:4.7.0 (com.azure.spring)
- Java version: 17
- App Server/Environment: Tomcat
- Frameworks: Spring Boot 2.7.10, Cosmos Emulator 2.14.12.0
If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:
- verbose dependency tree (
mvn dependency:tree -Dverbose) - exception message, full stack trace, and any available logs
NA
Additional context
NA
Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added

