April 27, 2020
Estimated Post Reading Time ~

How to get the published date of a page through Java API - AEM

This post will explain how to get the published date of a page through Java API in AEM

public static Date getPublishDate(Page page) {
 Date newDate = null;
 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd", Locale.getDefault());
 if (page != null) {
 String publishedDate =  page.getProperties().get("publisheddate", "");
 if(!"".equals(publishedDate)){
 try {
 newDate = sdf.parse(publishedDate);
 } catch (ParseException e) {

 }
 }
 }
 return newDate;
 }


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.