over 7 years ago
Hello guys, Some programmers many time faces difficulty while changing date format in liferay. Therefore By Below example, I am going to guide you How to change date format in liferay? Given bellow is the date format in GMT of liferay
"E MMM dd HH:mm:ss 'GMT' yyyy" 4 Nov 2014 10:08:28 GMT
Now , retrieve record created date :
List<DDLRecord> ddlRecordnew = null; try { ddlRecordnew = DDLRecordLocalServiceUtil.getDDLRecords(-1,Integer.MAX_VALUE); if (ddlRecordnew != null) { for (int i = 0; i < ddlRecordnew.size(); i++) { String createDate=ddlRecordnew.get(i).getCreateDate().toGMTString(); System.out.println(createDate); // output :4 Nov 2014 10:08:28 GMT } } } catch(Exception e) { }
If you want to change date format of createDate
//applyPattern("E MMM dd HH:mm:ss 'GMT' yyyy"); 4 Nov 2014 10:08:28 GMT Date dt = new SimpleDateFormat("d MMM yyyy HH:mm:ss 'GMT'").parse(createDate); //applyPattern("yyyy/MM/dd"); String createDate = new SimpleDateFormat("yyyy/MM/dd").format(dt);
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)