Top Description Inners Fields Constructors Methods
org.apache.juli

public Class DateFormatCache

extends Object
Class Inheritance
Imports
java.text.SimpleDateFormat, java.util.Date, .Locale, .TimeZone

Cache structure for SimpleDateFormat formatted timestamps based on seconds.

Millisecond formatting using S is not supported. You should add the millisecond information after getting back the second formatting.

The cache consists of entries for a consecutive range of seconds. The length of the range is configurable. It is implemented based on a cyclic buffer. New entries shift the range.

The cache is not threadsafe. It can be used without synchronization via thread local instances, or with synchronization as a global cache.

The cache can be created with a parent cache to build a cache hierarchy. Access to the parent cache is threadsafe.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final DateFormatCache.Cache
private final int
private final String
public static final char

Constructor Summary

AccessConstructor and Description
public
DateFormatCache(int size, String format, DateFormatCache parent)

Method Summary

Modifier and TypeMethod and Description
public String
getFormat(long time)

public String
private String
tidyFormat(String format)

Replace the millisecond formatting character 'S' by some dummy characters in order to make the resulting formatted time stamps cacheable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final DateFormatCache.Cache cache
cacheSizeback to summary
private final int cacheSize
formatback to summary
private final String format
MSEC_PATTERNback to summary
public static final char MSEC_PATTERN

Constructor Detail

DateFormatCacheback to summary
public DateFormatCache(int size, String format, DateFormatCache parent)

Method Detail

getFormatback to summary
public String getFormat(long time)
getTimeFormatback to summary
public String getTimeFormat()
tidyFormatback to summary
private String tidyFormat(String format)

Replace the millisecond formatting character 'S' by some dummy characters in order to make the resulting formatted time stamps cacheable. Our consumer might choose to replace the dummy chars with the actual milliseconds because that's relatively cheap.

org.apache.juli back to summary

private Class DateFormatCache.Cache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private String[]
private final Date
private long
private SimpleDateFormat
private long
private int
private DateFormatCache.Cache
private String
private long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private String
getFormat(long time)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private String[] cache
currentDateback to summary
private final Date currentDate
firstback to summary
private long first
formatterback to summary
private SimpleDateFormat formatter
lastback to summary
private long last
offsetback to summary
private int offset
parentback to summary
private DateFormatCache.Cache parent
previousFormatback to summary
private String previousFormat
previousSecondsback to summary
private long previousSeconds

Constructor Detail

Cacheback to summary
private Cache(DateFormatCache.Cache parent)

Method Detail

getFormatback to summary
private String getFormat(long time)