mirror of
https://github.com/jlengrand/github-api.git
synced 2026-03-10 08:21:21 +00:00
moved the convenience method here so that I can use it from elsewhere
This commit is contained in:
@@ -27,7 +27,6 @@ import com.gargoylesoftware.htmlunit.ElementNotFoundException;
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlButton;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlForm;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlInput;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
@@ -36,8 +35,6 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -119,19 +116,11 @@ public class GHRepository {
|
||||
}
|
||||
|
||||
public Date getPushedAt() {
|
||||
return parseDate(pushed_at);
|
||||
return GitHub.parseDate(pushed_at);
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return parseDate(created_at);
|
||||
}
|
||||
|
||||
private Date parseDate(String timestamp) {
|
||||
try {
|
||||
return new SimpleDateFormat(TIME_FORMAT).parse(timestamp);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalStateException("Unable to parse the timestamp: "+pushed_at);
|
||||
}
|
||||
return GitHub.parseDate(created_at);
|
||||
}
|
||||
|
||||
|
||||
@@ -385,6 +374,4 @@ public class GHRepository {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String TIME_FORMAT = "yyyy/MM/dd HH:mm:ss ZZZZ";
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ import java.io.InterruptedIOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -243,7 +246,7 @@ public class GitHub {
|
||||
return wc;
|
||||
}
|
||||
|
||||
/*package*/ static URL toURL(String s) {
|
||||
/*package*/ static URL parseURL(String s) {
|
||||
try {
|
||||
return s==null ? null : new URL(s);
|
||||
} catch (MalformedURLException e) {
|
||||
@@ -251,8 +254,18 @@ public class GitHub {
|
||||
}
|
||||
}
|
||||
|
||||
/*package*/ static Date parseDate(String timestamp) {
|
||||
try {
|
||||
return new SimpleDateFormat(TIME_FORMAT).parse(timestamp);
|
||||
} catch (ParseException e) {
|
||||
throw new IllegalStateException("Unable to parse the timestamp: "+timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
/*package*/ static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
private static final String TIME_FORMAT = "yyyy/MM/dd HH:mm:ss ZZZZ";
|
||||
|
||||
static {
|
||||
MAPPER.setVisibilityChecker(new Std(NONE, NONE, NONE, NONE, ANY));
|
||||
MAPPER.getDeserializationConfig().set(Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
|
||||
Reference in New Issue
Block a user