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.
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final DateFormatCache. | |
| private final int | |
| private final String | |
| public static final char |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| 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. |
| cache | back to summary |
|---|---|
| private final DateFormatCache. | |
| cacheSize | back to summary |
|---|---|
| private final int cacheSize | |
| format | back to summary |
|---|---|
| private final String format | |
| MSEC_PATTERN | back to summary |
|---|---|
| public static final char MSEC_PATTERN | |
| DateFormatCache | back to summary |
|---|---|
| public DateFormatCache(int size, String format, DateFormatCache parent) | |
| getFormat | back to summary |
|---|---|
| public String getFormat(long time) | |
| getTimeFormat | back to summary |
|---|---|
| public String getTimeFormat() | |
| tidyFormat | back 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. | |
| Modifier and Type | Field and Description |
|---|---|
| private String[] | |
| private final Date | |
| private long | |
| private SimpleDateFormat | |
| private long | |
| private int | |
| private DateFormatCache. | |
| private String | |
| private long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private String |
| cache | back to summary |
|---|---|
| private String[] cache | |
| currentDate | back to summary |
|---|---|
| private final Date currentDate | |
| first | back to summary |
|---|---|
| private long first | |
| formatter | back to summary |
|---|---|
| private SimpleDateFormat formatter | |
| last | back to summary |
|---|---|
| private long last | |
| offset | back to summary |
|---|---|
| private int offset | |
| parent | back to summary |
|---|---|
| private DateFormatCache. | |
| previousFormat | back to summary |
|---|---|
| private String previousFormat | |
| previousSeconds | back to summary |
|---|---|
| private long previousSeconds | |
| Cache | back to summary |
|---|---|
| private Cache(DateFormatCache. | |
| getFormat | back to summary |
|---|---|
| private String getFormat(long time) | |