Date value is not populating in page and not retain in dialog | Community
Skip to main content
Aug 3, 2017 8:57 AM UTC
Solved

Date value is not populating in page and not retain in dialog

HI,

I am not able to populate the Date value from datepicker. Please find the JCR nodes below:

code in sightly <h1>${properties.doe}</h1>

Regards,

Sandhya.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
susheel
susheelAccepted solution
Level 5
Aug 3, 2017 2:24 PM UTC

Hi sandhya,

For the value storage datetime will work as we discussed. Seems like format in sightly is not working in 6.2. So we need to write a formatter like below for your component.

package apps.project.components.author.componentname;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import com.adobe.cq.sightly.WCMUsePojo;

public class DateFormatter extends WCMUsePojo {

    private String formattedDate;

    @Override

    public void activate() {

    Calendar date  = get("date", Calendar.class);

    String format =  get("format",String.class);

    SimpleDateFormat formatter = new SimpleDateFormat(format);

    formattedDate = formatter.format(date.getTime());

    }   

    public String getFormattedDate() {

        return formattedDate;

    }

}

<sly data-sly-use.date="${'DateFormatter' @ date=properties.doe,format='dd/MM/yyyy'}">
    ${date.formattedDate}
</sly>

14 replies

smacdonald2008
Level 10
Dec 5, 2017 1:27 AM UTC

We have a new article that shows use of displaying a DATE value in HTL -- also Sling Model and Coral 3 Multi-Field - https://helpx.adobe.com/experience-manager/using/multifield_coral_aem63.html

Translate
Aug 4, 2017 6:54 AM UTC

Thank you so much for your help and quick response.

Translate
susheel
Level 5
Aug 3, 2017 5:57 PM UTC

Thanks smacdonald2008

Translate
smacdonald2008
Level 10
Aug 3, 2017 5:22 PM UTC

susheel singh - great community interaction here

Translate
susheel
susheelAccepted solution
Level 5
Aug 3, 2017 2:24 PM UTC

Hi sandhya,

For the value storage datetime will work as we discussed. Seems like format in sightly is not working in 6.2. So we need to write a formatter like below for your component.

package apps.project.components.author.componentname;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import com.adobe.cq.sightly.WCMUsePojo;

public class DateFormatter extends WCMUsePojo {

    private String formattedDate;

    @Override

    public void activate() {

    Calendar date  = get("date", Calendar.class);

    String format =  get("format",String.class);

    SimpleDateFormat formatter = new SimpleDateFormat(format);

    formattedDate = formatter.format(date.getTime());

    }   

    public String getFormattedDate() {

        return formattedDate;

    }

}

<sly data-sly-use.date="${'DateFormatter' @ date=properties.doe,format='dd/MM/yyyy'}">
    ${date.formattedDate}
</sly>

Translate
Aug 3, 2017 10:41 AM UTC

HI Susheel,

I have requested for the access,Please provide the permission to access  google drive.

Regards,

Sandhya.

Translate
susheel
Level 5
Aug 3, 2017 10:36 AM UTC
Aug 3, 2017 10:24 AM UTC

Can you please share your code(pkg),so that i can compare with my code.

Regards,

Sandhya.

Translate
Aug 3, 2017 10:22 AM UTC

HI,

Yes,DOE value is storing under content node.

On page :: trying to get value from  ${'YYYY-MM-DD' @ format=properties.doe,type='datetime'}

  \

After updating to datetime, did you save the datetime value from dialog. -- Saving in dialog means value node?

Translate
susheel
Level 5
Aug 3, 2017 10:15 AM UTC

You are sharing the component node screenshot.

I am asking about the /content where the component is created.

After updating to datetime, did you save the datetime value from dialog.

If yes what do you see exactly on your page, can you add screenshot.

Which version of AEM are you using. I tested this on AEM 6.3

Translate