I'm working on an android app with gae as backend. I have two queries around DateTime object com.google.gdata.data.DateTime
While inserting data, I only want to to insert date and not datetime. Here's current object creation and it saves both date and time.
stock.setDate(new DateTime(new Date()));
Also while retrieving stock object, where I have aggregated data, I want to group by date and not datetime. But as the data got stored as date and time, I'm getting group by datetime, where as I want date. What to do in such scenarios (yes, if we solve 1st problem this wont be required, but otherwise what should be done). My retrieval code is
List<AggregatedStock> execute = null; PersistenceManager pm = getPersistenceManager(); Query query = pm .newQuery(" select date, vehicleCode, vehicleSubCode, colorCode, sum(count) from Stock as AggregatedStock "); query.setFilter(" updatedByDealer == " + dealer); query.setGrouping(" date, vehicleCode, vehicleSubCode, colorCode "); query.setOrdering(" vehicleCode desc "); query.declareImports("import com.sandeepapplabs.dms.Stock"); try { List<Object[]> results = (List<Object[]>) query.execute(); execute = new ArrayList<AggregatedStock>(); for (Object[] result : results) { execute.add(new AggregatedStock((Date) result[0], (String) result[1], (String) result[2], (String) result[3], ((Long) result[4]).intValue())); } } finally { pm.close(); } return execute;