Index: subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java =================================================================== --- subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java (revision 0) +++ subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java (revision 0) @@ -0,0 +1,109 @@ +/** + * @copyright + * ==================================================================== + * Copyright (c) 2008 CollabNet. All rights reserved. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://subversion.tigris.org/license-1.html. + * If newer versions of this license are posted there, you may use a + * newer version instead, at your option. + * + * This software consists of voluntary contributions made by many + * individuals. For exact contribution history, see the revision + * history and logs, available at http://subversion.tigris.org/. + * ==================================================================== + * @endcopyright + */ + +package org.tigris.subversion.javahl; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Holds date for a log message. This class maintains + * the time to the microsecond and is not lossy. + * + * @since 1.5 + */ +public class LogDate implements java.io.Serializable +{ + private static final long serialVersionUID = 1L; + private static final DateFormat formatter = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss.SSS"); + + private long timeMicros; + private Date cachedDate; + + public LogDate(long timeMicros) + { + super(); + this.timeMicros = timeMicros; + } + + /** + * Returns the time of the commit + * @return the time of the commit measured in the number of + * microseconds since 00:00:00 January 1, 1970 UTC + */ + public long getTimeMicros() + { + return timeMicros; + } + + /** + * Returns the time of the commit + * @return the time of the commit measured in the number of + * milliseconds since 00:00:00 January 1, 1970 UTC + */ + public long getTimeMillis() + { + return timeMicros / 1000; + } + + /** + * Returns the date of the commit + * @return the date of the commit + */ + public Date getDate() + { + if (cachedDate == null) + { + cachedDate = new Date(timeMicros / 1000); + } + return cachedDate; + } + + @Override + public String toString() + { + return formatter.format(getDate()); + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + (int) (timeMicros ^ (timeMicros >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final LogDate other = (LogDate) obj; + if (timeMicros != other.getTimeMicros()) + return false; + return true; + } + +} Property changes on: subversion/bindings/javahl/src/org/tigris/subversion/javahl/LogDate.java ___________________________________________________________________ Added: svn:eol-style + native Index: subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java =================================================================== --- subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java (revision 31386) +++ subversion/bindings/javahl/src/org/tigris/subversion/javahl/SVNClient.java (working copy) @@ -25,10 +25,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Date; -import java.util.Calendar; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.text.ParseException; /** * This is the main client class. All Subversion client APIs are @@ -1374,29 +1370,13 @@ { String author = (String) revprops.get("svn:author"); String message = (String) revprops.get("svn:log"); - long timeMicros; + LogDate date = (LogDate) revprops.get("svn:date"); + if (date == null) date = new LogDate(0); - // Really hacky date parser, because Java doesn't support - // microseconds natively. - try { - DateFormat formatter = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSS"); - String datestr = ((String) revprops.get("svn:date")); - Date date = formatter.parse(datestr.substring(0, 23)); - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - timeMicros = cal.getTimeInMillis(); - - timeMicros = timeMicros * 1000 - + Integer.parseInt(datestr.substring(23, 26)); - } catch (ParseException ex) { - timeMicros = 0; - } - LogMessage msg = new LogMessage(changedPaths, revision, author, - timeMicros, + date.getTimeMicros(), message); /* Filter out the SVN_INVALID_REVNUM message which pre-1.5