I am using Java to Query Azure table storage service.
I am querying a Azure table based on TimeStamp. Before executing query I converted the local java date to UTC.
Query is throwing an TableServiceException "One of the request inputs is not valid. RequestId:59445f16-0002-007e-152d-b3e24d000000 Time:2016-05-21T06:50:34.5077574Z"
When I used same date and query data using Azure Storage explorer; I am able to get the desired value as shown in below screen shot.
http://puu.sh/oZD6y/eadcc45859.png This makes me wonder what am I doing wrong.
below is the code that I use to query Azure Table. endDate is of Type Date
String partitionFilter = TableQuery.generateFilterCondition(PARTITION_KEY, QueryComparisons.EQUAL,
partitionKey);
String date2 = TableQuery.generateFilterCondition(TIMESTAMP, QueryComparisons.LESS_THAN_OR_EQUAL, endDate.getTime());
String finalFilter = TableQuery.combineFilters(partitionFilter, Operators.AND, date2);
CloudTable table = getTable(tableName);
TableQuery<TableServiceEntity> query = TableQuery.from(TableServiceEntity.class).where(finalFilter);
Iterable<TableServiceEntity> tableEntries = table.execute(query);
return tableEntries;
Below code is used to convert local date
long ts = System.currentTimeMillis();
Date localTime = new Date(ts);
String format = "yyyy/MM/dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat (format);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date gmtTime = new Date(sdf.format(localTime));
System.out.println("Local:" + localTime.toString() + "," + localTime.getTime() + " --> UTC time:" + gmtTime.toString() + "-" + gmtTime.getTime());
This already wasted my time a lot. Any help would be highly appreciated.
date2
variable? In fact, it would be much simpler if you show the value offinalFilter
. – Gaurav Mantri