From json, i am getting the value as
"createdOn": "Jan 08 2015 20:40:56 GMT+0530 (IST)",
I am Accessing in FTL
<#list variables as variable>
<div class="reply">
${variable.createdOn}
</div>
</#list>
The result i am getting is
Jan 09 2015 12:36:18 GMT+0530 (IST)
My preferable format is
09-01-2015
I need to remove rest of the time GMT, IST and so on.
How to convert this in Freemarker template or javascript.
Update
I tried to pass below like this
${variable.createdOn?datetime?string("dd-MM-yyyy")}
but it is giving error as
Exception: java.text.ParseException - Unparseable date: "Jan 09 2015 12:36:18 GMT+0530 (IST)"
Any help is Appreciated.
Thanks
Select the dates you want to convert, right click to select Format Cells from context menu. 2. In the Format Cells dialog, under Number tab, select Date from Category list, and then select one format you want to convert to from the right section.
Date from one format to another using SimpleDateFormat. We can convert a java. util. Date from one format to another using SimpleDateFormat.
You can convert a DATETIME to a DATE using the CONVERT function. The syntax for this is CONVERT (datetime, format). This shows the date only and no time.
First of all, what format is that at all? I mean, if you can influence someone to use a standard format instead (ISO, mostly) that will help everyone. Anyway, FreeMarker isn't a date parser library, but actually you can do something like this:
<#-- Settings you need -->
<#setting date_format="dd-MM-yyyy">
<#setting locale="en_US">
<#-- The string that comes from somewhere: -->
<#assign createdOn = 'Jan 08 2015 20:40:56 GMT+0530 (IST)'>
<#--
1. Tell FreeMarker to convert string to real date-time value
2. Convert date-time value to date-only value
3. Let FreeMarker format it according the date_format setting
-->
${createdOn?datetime("MMM dd yyyy HH:mm:ss 'GMT'Z")?date}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With