Connector Fetch REST API - How do I show a human readable date in Visualforce pages
Add-on: | Classic Connector for Salesforce & Jira |
---|---|
Question: | Connector Fetch REST API - How do I show a human readable date in Visualforce pages |
Answer: | When using the REST API to fetch JIRA issue date data, it will return the value in epoch date format. You will need to manually convert the value to a more human readable format using code such as the following: // JIRA Issue Object. @testVisible class JIRAIssue { ... public String due_date { get; } public String getFormattedDueDate() { if(this.due_date != null && this.due_date != '') { return DateTime.newInstance(Long.valueof(this.due_date)).format('dd/MM/yyyy', UserInfo.getTimeZone().getID()); } return null; } }
In the Visualforce page, add a new column which refer to the new method created above: <apex:pageBlockTable value="{!Issues}" var="issue"> ... <apex:column headerValue="Due Date" value="{!issue.formattedDueDate}"/> </apex:pageBlockTable> |