LuxuryMaster LuxuryMaster - 2 months ago 22
Java Question

Java - GAE Datastore persisting Date with specific format

I have a Google app engine JDO datastore entity with a date field and it looks like the following.

public class Test {

@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;

private Date dateTime;


The problem I'm having is it defaults to datetime (2014-08-30 00:00:00.000Z) format which is not how I want to store the date. I want to define specific format 'yyyy-MM-dd'.

Looks like there's support for python to do this. However, I can't find similar documentation for Java.

How can I change the datastore entity definition to support what I'm trying to accomplish?


Datastore will always store dates as UTC along with the time and tzinfo=None included. There is no method to override this on Java neither on Pyhton as explained here [1].

The exception is that in Python there is a class that will retrieve the "raw" date from Datastore and display the date part of it. This won't prevent Datastore from storing the date with the full format.

In short, all you can do is ignore the time data and manipulate the data retrieved from Datastore with the aproppiate functions [2] to get only the date.