I think this is a bug or an oversight, but I can't really prove it.
The Time
class in Salesforce is very limited, especially compared to the DateTime
class. It doesn't even have its own format
method, which I think may be the underlying problem here. Without a format
method to accept the formatting string, Salesforce might not be able to properly format the field, but the error reported doesn't seem to relate.. although a value which cannot be formatted could be considered an invalid value in this case.
I also think the Time
option for the apex:outputText
was not meant for this field, but rather, the Time
component of a DateTime
class. For example, in the code below, I'm using the Time
option in the value, but I'm using a DateTime
field, and it renders without any problems.
<apex:outputText value="{0, Time, HH:mm:ss z}">
<apex:param value="{!someAccount.CreatedDate}"/> <!-- Date/Time field -->
</apex:outputText>
The same outputText
causes a compile error if we try to use a Time field instead.
<apex:outputText value="{0, Time, HH:mm:ss}">
<apex:param value="{!someAccount.Test_Time__c}"/>
</apex:outputText>
The value attribute on <apex:outputText>
is not in a valid format. It must be a positive number, and of type Number, Date, Time, or Choice.
As for a solution, I would do the formatting myself in the controller, instead of relying on the visualforce to do it for me.
Apex:
public String getFormattedTime() {
return SomeAccount.Test_Time__c.hour() + ':' + SomeAccount.Test_Time__c.minute();
}
Visualforce:
<apex:outputText value="{!FormattedTime}" />