package tigase.jaxmpp.j2se;

import java.text.SimpleDateFormat;
import java.util.Date;

import tigase.jaxmpp.core.client.xmpp.utils.DateTimeFormat.DateTimeFormatProvider;

public class DateTimeFormatProviderImpl implements DateTimeFormatProvider {

	private final SimpleDateFormat d1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

	private final SimpleDateFormat d2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");

	@Override
	public String format(Date date) {
		return d1.format(date);
	}

	@Override
	public Date parse(String t) {
		try {
			return d1.parse(t);
		} catch (Exception e) {
			try {
				return d2.parse(t);
			} catch (Exception e1) {
				return null;
			}
		}
	}

}

@@ -79,16 +79,43 @@
 il.Date;
+%0Aimport java.util.TimeZone;
 %0A%0Aimport
@@ -301,16 +301,62 @@
 eFormat 
+d1;%0A%0A%09public DateTimeFormatProviderImpl() %7B%0A%09%09
 d1 = new
@@ -406,93 +406,57 @@
 %22);%0A
-%0A%09private final SimpleDateFormat d2 = new SimpleDateFormat(%22yyyy-MM-dd'T'HH:mm:ssZ%22);
+%09%09d1.setTimeZone(TimeZone.getTimeZone(%22GMT%22));%0A%09%7D
 %0A%0A%09@
@@ -499,16 +499,53 @@
 date) %7B%0A
+%09%09Date d = new Date(date.getTime());%0A
 %09%09return
@@ -556,19 +556,16 @@
 format(d
-ate
 );%0A%09%7D%0A%0A%09
@@ -666,70 +666,8 @@
 ) %7B%0A
-%09%09%09try %7B%0A%09%09%09%09return d2.parse(t);%0A%09%09%09%7D catch (Exception e1) %7B%0A%09
 %09%09%09r
@@ -682,13 +682,8 @@
 ll;%0A
-%09%09%09%7D%0A
 %09%09%7D%0A

fix parsing and formating time