mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-30 02:02: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:
parent
d1893d541e
commit
0ca8b726bd
1 changed files with 4 additions and 5 deletions
|
@ -21,6 +21,7 @@ import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.UnknownFormatConversionException;
|
import java.util.UnknownFormatConversionException;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
import org.jivesoftware.smackx.Form;
|
import org.jivesoftware.smackx.Form;
|
||||||
import org.jivesoftware.smackx.FormField;
|
import org.jivesoftware.smackx.FormField;
|
||||||
import org.jivesoftware.smackx.packet.DataForm;
|
import org.jivesoftware.smackx.packet.DataForm;
|
||||||
|
@ -37,8 +38,6 @@ import org.jivesoftware.smackx.packet.DataForm;
|
||||||
*/
|
*/
|
||||||
public class SubscribeForm extends Form
|
public class SubscribeForm extends Form
|
||||||
{
|
{
|
||||||
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
|
|
||||||
|
|
||||||
public SubscribeForm(DataForm configDataForm)
|
public SubscribeForm(DataForm configDataForm)
|
||||||
{
|
{
|
||||||
super(configDataForm);
|
super(configDataForm);
|
||||||
|
@ -127,7 +126,7 @@ public class SubscribeForm extends Form
|
||||||
String dateTime = getFieldValue(SubscribeOptionFields.expire);
|
String dateTime = getFieldValue(SubscribeOptionFields.expire);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return format.parse(dateTime);
|
return StringUtils.parseDate(dateTime);
|
||||||
}
|
}
|
||||||
catch (ParseException e)
|
catch (ParseException e)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +144,7 @@ public class SubscribeForm extends Form
|
||||||
public void setExpiry(Date expire)
|
public void setExpiry(Date expire)
|
||||||
{
|
{
|
||||||
addField(SubscribeOptionFields.expire, FormField.TYPE_TEXT_SINGLE);
|
addField(SubscribeOptionFields.expire, FormField.TYPE_TEXT_SINGLE);
|
||||||
setAnswer(SubscribeOptionFields.expire.getFieldName(), format.format(expire));
|
setAnswer(SubscribeOptionFields.expire.getFieldName(), StringUtils.formatXEP0082Date(expire));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue