[jboss-svn-commits] JBoss Common SVN: r3681 - jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/handlers.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Nov 12 21:17:12 EST 2009
Author: david.lloyd at jboss.com
Date: 2009-11-12 21:17:12 -0500 (Thu, 12 Nov 2009)
New Revision: 3681
Modified:
jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java
Log:
Allow time zone to be specified in periodic rotating file handler
Modified: jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java
===================================================================
--- jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java 2009-11-12 10:09:55 UTC (rev 3680)
+++ jboss-logmanager/trunk/src/main/java/org/jboss/logmanager/handlers/PeriodicRotatingFileHandler.java 2009-11-13 02:17:12 UTC (rev 3681)
@@ -26,6 +26,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
+import java.util.TimeZone;
import java.io.File;
import java.io.FileNotFoundException;
@@ -41,6 +42,7 @@
private String nextSuffix;
private Period period = Period.NEVER;
private long nextRollover = Long.MAX_VALUE;
+ private TimeZone timeZone = TimeZone.getDefault();
/**
* Construct a new instance with no formatter and no output file.
@@ -115,6 +117,7 @@
*/
public void setSuffix(String suffix) throws IllegalArgumentException {
final SimpleDateFormat format = new SimpleDateFormat(suffix);
+ format.setTimeZone(timeZone);
final int len = suffix.length();
Period period = Period.NEVER;
for (int i = 0; i < len; i ++) {
@@ -166,7 +169,7 @@
return;
}
nextSuffix = format.format(new Date(fromTime));
- final Calendar calendar = Calendar.getInstance();
+ final Calendar calendar = Calendar.getInstance(timeZone);
calendar.setTimeInMillis(fromTime);
final Period period = this.period;
// clear out less-significant fields
@@ -217,6 +220,27 @@
nextRollover = calendar.getTimeInMillis();
}
+ /**
+ * Get the configured time zone for this handler.
+ *
+ * @return the configured time zone
+ */
+ public TimeZone getTimeZone() {
+ return timeZone;
+ }
+
+ /**
+ * Set the configured time zone for this handler.
+ *
+ * @param timeZone the configured time zone
+ */
+ public void setTimeZone(final TimeZone timeZone) {
+ if (timeZone == null) {
+ throw new NullPointerException("timeZone is null");
+ }
+ this.timeZone = timeZone;
+ }
+
private static <T extends Comparable<? super T>> T min(T a, T b) {
return a.compareTo(b) <= 0 ? a : b;
}
More information about the jboss-svn-commits
mailing list