Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change dateformat of DDLRecord created date in Liferay 6.2

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 835
    Comment on it

    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 &lt; 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);
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: