cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco DateFormat

german
Champ on-the-rise
Champ on-the-rise
Hi all.
Using Java and mySQL I have a problem in setting the Date property of a document before to load it on Alfresco.
To set the other properties I use JTextField and I have no problems, because they are text fields.
What can I use in Java to set a property type in the date format accepted by Alfresco?

NamedValue[] propertiesC = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, TxtName.getText() + ".pdf"), Utils.createNamedValue("{extension.myModel}MyDate", ????????????? )};

Thanks in advance.

Bye.

Germano
2 REPLIES 2

jos_snellings
Champ in-the-making
Champ in-the-making
The date in format yyyy-mm-ddThh:mm:ss.sssZ

will do. This method grabs a date (raw) that was available as yyyymmdd and returns the date in the requested format.
This is maybe close to what you need?

private String formatDate(String raw)
{
String yyyy = raw.substring(0,4);
String mm   = raw.substring(4,6);
String dd   = raw.substring(6,8);
StringBuffer res = new StringBuffer();
res.append(yyyy);
res.append("-");
res.append(mm);
res.append("-");
res.append(dd);
res.append("T00:00:00.000Z");
return res.toString();
}

Cheers,
Jos

german
Champ on-the-rise
Champ on-the-rise
Thank you very much, you are the best.
Bye.

Germano