[SalesForce] Date input taking into account users time zone offset

I have an input field that is binding to a backing Task in the controller to allow users to enter a date into the ActivityDate field.

I'm not interested in any other fields on the Task. I'm just using it as a mechanism to get the date picker.

Controller:

public Task startDateTask {get; set;}

Page:

<apex:inputField value="{!startDateTask.ActivityDate}"/>

Taking into account the users time zone offset, how can I determine the Date the user entered in UTC/GMT?

The Date primitive data type doesn't appear to have any of the GMT methods that DateTime has. This makes sense, as there is no offset information in just a date without a time.

But when a user that is in a UTC +12 timezone enters the same date as a UTC -10 user they are not talking about the same day of the year. This causes issues when passing the dates off to a web service.

Best Answer

Date is timezone non-aware, in fact, so is datetime (its stored at the server as GMT and re-rendered based on users TZ).
Unless you hard-code a base time for your date in Apex code/Trigger, your going to want store a datetime value instead of a date. If you dont want the time part to show up, look into creating a formula field that renders the date based upon the (hidden) datetime field. That should maintain the correct date rendered for their timezone.