Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

sandhyap2357299
Level 3
Level 3

HI,

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

1271176_pastedImage_0.png

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

Regards,

Sandhya.

1 Accepted Solution
susheel
Correct answer by
Level 5
Level 5

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>

View solution in original post

0 Replies
susheel
Level 5
Level 5

Hi Sandhya,

Can you check the same thing in firefox browser, if the value is getting retained or not.

If the issue still exists you can use type as datetime to fix it temporarily.

We also faced this issue in chrome due to some browser restrictions.

Coming to display part:

As this is a date picker. It is stored as Date object, so you need to read the values as below.

Date: ${'dd-MM-yyyy' @ format=properties.doe]}
(or)

Date: ${'dd-MM-yyyy HH:mm' @ format=properties.doe, timezone='GMT+05:30'}

Go through this link as well : htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub

sandhyap2357299
Level 3
Level 3

Hi Susheel,

I have tried changing the type="date" to "datetime",Value is retaining in dialog But still it is not displaying on page even after giving

${'MMM-dd-yyyy' @ format=properties.doe,type='datetime'}

It just displaying  "MMM-dd-yyyy" on page.

1271307_pastedImage_0.png

Regards,

Sandhya.

susheel
Level 5
Level 5

can you show the stored value node ?

For me Its working fine.

sandhyap2357299
Level 3
Level 3

Hi Susheel,

1271308_pastedImage_0.png

${'YYYY-MM-DD' @ format=properties.doe,type='datetime'}

Couldn't able to reply to your mail,its not delivering.

susheel
Level 5
Level 5

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

sandhyap2357299
Level 3
Level 3

HI,

Yes,DOE value is storing under content node.

1271330_pastedImage_0.png

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

1271331_pastedImage_1.png  \

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

sandhyap2357299
Level 3
Level 3

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

Regards,

Sandhya.

sandhyap2357299
Level 3
Level 3

HI Susheel,

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

Regards,

Sandhya.

susheel
Correct answer by
Level 5
Level 5

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>

View solution in original post

smacdonald2008
Level 10
Level 10

susheel singh - great community interaction here

sandhyap2357299
Level 3
Level 3

Thank you so much for your help and quick response.

smacdonald2008
Level 10
Level 10

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