Error using Java API to update list filters

I am attempting to update a filter daily, using the Java API.

The field is a date field, called membership_end_date.

When I attempt to do this using java, I get this error message:

Dates with greater than filters must specify the end of the day as the timestamp

My date, in milliseconds, is set to the end of the current day:

1560398399999

Which, in plain text, is…

Wed Jun 12 23:59:59 EDT 2019

Here is my JSON:

{
 "name": "Active Members List",
 "filters": [
 [
 {
 "withinTimeMode": "PAST",
 "filterFamily": "PropertyValue",
 "property": "membership_end_date",
 "type": "date",
 "value": 1560398399999,
 "operator": "IS_NOT_EMPTY"
 },
 {
 "withinTimeMode": "PAST",
 "filterFamily": "PropertyValue",
 "property": "membership_end_date",
 "type": "date",
 "value": 1560398399999,
 "operator": "GT"
 },
 {
 "withinTimeMode": "PAST",
 "filterFamily": "PropertyValue",
 "property": "current_membership",
 "type": "string",
 "value": "Membership",
 "operator": "CONTAINS"
 }
 ]
 ]
}

Hi, @mclayton.

HubSpot accepts epoch timestamps in UTC (0:00), so I think the issue is that 1560398399999 comes out to Thursday, June 13, 2019 at 03:59:59.999 UTC.

Could you try 1560383999999?

I’m generating this timestamp with Java.

1560571199999
Fri Jun 14 23:59:59 EDT 2019

Also, 1560398399999 comes out to Wed 12 June 2019
23:59:59 when I use an online date converter.

Check your numbers again?

Hi, @mclayton.

My numbers are correct. You must use a timestamp that reflects 23:59:59.999 in UTC/GMT 0:00 on the desired date, not 23:59:59.999 in your local time zone (e.g. EDT,or UTC -4:00).

When I attempt to update one of my own list filters with the EDT timestamp 1560916799999 (Tuesday, June 18, 2019 at 23:59:59.999 EDT):

{
 "filters": [
 [
 {
 "withinTimeMode": "PAST",
 "operator": "GT",
 "filterFamily": "PropertyValue",
 "type": "date",
 "property": "custom_date_picker",
 "value": 1560916799999
 }
 ]
 ]
}

… I receive the following error:

{
 "status": "error",
 "message": "Dates with greater than filters must specify the end of the day as the timestamp",
 "correlationId": "fb2eba9a-6015-427c-9989-7cbeae9fced0",
 "requestId": "eda7e04e7010e7959ae4ad6cce1d39a1"
}

However, when I use a timestamp reflecting Tuesday, June 18, 2019 at 23:59:59.999 in the UTC/GMT time zone — 1560902399999:

{
 "filters": [
 [
 {
 "withinTimeMode": "PAST",
 "operator": "GT",
 "filterFamily": "PropertyValue",
 "type": "date",
 "property": "custom_date_picker",
 "value": 1560902399999
 }
 ]
 ]
}

…I receive a 200 response and the update takes.

Seems to be working.

Only thing I did differently was to setTimeZone(…)

Thanks @IsaacTakushi

Date day = new Date();
	 Calendar cal = Calendar.getInstance(); 
	cal.setTime(day);
	 cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY));
	 cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE));
	 cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND));
	 cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND));
	 cal.setTimeZone(TimeZone.getTimeZone("UTC"));