1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-26 16:22:06 +01:00

PubSub SubcribeForm: Use new StringUtils.formatXEP0082Date to get the correct date string. Note that the previous used SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss.SSSZ" did not produce XEP-0082 conforming strings, since Z is replace with e.g. '+0100' whereas it should be '+01:00'.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13434 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-02-04 13:33:15 +00:00 committed by flow
parent d1893d541e
commit 0ca8b726bd

View file

@ -21,6 +21,7 @@ import java.util.Date;
import java.util.Iterator;
import java.util.UnknownFormatConversionException;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.Form;
import org.jivesoftware.smackx.FormField;
import org.jivesoftware.smackx.packet.DataForm;
@ -36,9 +37,7 @@ import org.jivesoftware.smackx.packet.DataForm;
* @author Robin Collier
*/
public class SubscribeForm extends Form
{
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
{
public SubscribeForm(DataForm configDataForm)
{
super(configDataForm);
@ -127,7 +126,7 @@ public class SubscribeForm extends Form
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try
{
return format.parse(dateTime);
return StringUtils.parseDate(dateTime);
}
catch (ParseException e)
{
@ -145,7 +144,7 @@ public class SubscribeForm extends Form
public void setExpiry(Date expire)
{
addField(SubscribeOptionFields.expire, FormField.TYPE_TEXT_SINGLE);
setAnswer(SubscribeOptionFields.expire.getFieldName(), format.format(expire));
setAnswer(SubscribeOptionFields.expire.getFieldName(), StringUtils.formatXEP0082Date(expire));
}
/**