Skip to content

Commit

Permalink
performance improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfram-zz committed Oct 22, 2013
1 parent 67253fc commit d5a4f91
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions projects/typetools/src/main/java/org/nohope/typetools/TTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
*/
public final class TTime {
public static final String UTC_ID = "UTC";
private static final DatatypeFactory datatypeFactory;

static {
try {
datatypeFactory = DatatypeFactory.newInstance();
} catch (DatatypeConfigurationException e) {
throw new RuntimeException(e);
}
}

private TTime() {
}
Expand Down Expand Up @@ -62,11 +71,6 @@ public static XMLGregorianCalendar toXmlCalendar(final Date date, final String t
final GregorianCalendar calendar = new GregorianCalendar();
calendar.setTimeZone(TimeZone.getTimeZone(timezoneId));
calendar.setTime(date);

try {
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
} catch (DatatypeConfigurationException e) {
throw new IllegalStateException(e);
}
return datatypeFactory.newXMLGregorianCalendar(calendar);
}
}

0 comments on commit d5a4f91

Please sign in to comment.