Skip to content

Instantly share code, notes, and snippets.

@brianm
Created January 23, 2009 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianm/51199 to your computer and use it in GitHub Desktop.
Save brianm/51199 to your computer and use it in GitHub Desktop.
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
public class TestDateParse
{
@Test
public void testFoo() throws Exception {
String d = "13/Feb/2008:15:33:39 -0800";
DateTimeFormatter dtf = DateTimeFormat.forPattern("dd/MMM/yyyy:HH:mm:ss Z");
DateTime dt = dtf.parseDateTime(d);
assertTrue(new DateTime(2008, 2, 13, 15, 33, 39, 0, DateTimeZone.forOffsetHours(-8)).isEqual(dt));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment