[below image is screenshot of my web page I am creating gae app that store some data in google datastore but having some difficulties with date format at client side i am using Anugularjs date as shown in image i want to store that date but also i want to separate day month and year of that date in java
Asked
Active
Viewed 513 times
1 Answers
0
Like on any other Java 7 system, a typical pattern (after the appropriate imports at the top of your Java code) would be:
Calendar calendar = new GregorianCalendar();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
That's because java.util.Date
, which used to be the natural way to do things, is mostly deprecated in Java 7 (though AFAIK it still works).
In Java 8 you'd use java.time
, but GAE does not yet support Java 8.

Alex Martelli
- 854,459
- 170
- 1,222
- 1,395
-
thanks @Alex but i stuck with angularjs date format, how to get that date in java object and perform operations on it?? – SylvesterTheKid Nov 22 '15 at 15:19
-
On the JS side, format the date as a string as per https://docs.angularjs.org/api/ng/filter/date and send it to the server as you would any other string; on the server side, parse the string back into a Calendar object as per e.g http://stackoverflow.com/questions/5301226/convert-string-to-calendar-object-in-java then proceed as above to extract year etc. Neither half is really a google-app-engine question at all: best tag it as angular-js! – Alex Martelli Nov 22 '15 at 15:43
-
okay I think this might help I try this one thanks a lot @Alex – SylvesterTheKid Nov 23 '15 at 08:16
-
@MayurPardeshi, if the answer helps, remember to accept it (click on the checkmark outline to the left of the answer) -- fundamental stackoverflow etiquette. – Alex Martelli Nov 23 '15 at 14:49