Hi there,

I'm writting a small piece of software that has to read and write dates as
plain text on a webservice I don't own nor control.

The format is:
"EEE, dd MMM yyyy HH:mm:ss z"

I can write the dates the way I want, but using the same exact pattern won't
read it back.

Here is a minimalist code to demonstrate the problem, using Joda 1.6.2:

---
package utilities;

import java.util.Locale;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class TimeFormats {
private static final DateTimeFormatter formater =
DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss
z").withLocale(Locale.US);
 public static String format(DateTime date) {
return formater.print(date);
}

public static DateTime parse(String string) {
return formater.parseDateTime(string);
}
 public static void main(String[] args) {
DateTime date = new
DateTime().withYear(2011).withMonthOfYear(5).withDayOfMonth(6).withHourOfDay(17).withMinuteOfHour(30).withSecondOfMinute(38).withMillisOfSecond(0).withZone(DateTimeZone.UTC);
System.out.println(parse(format(date)));
}
}
---

Has anyone an idea of what's going wrong? I can't find any clue on such a
simple subject...

Thank you for reading and helping...

Mathieu Bolla
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to