Copyright© 2008-2022 Sitevision AB, all rights reserved.
@Requireable(value="TimestampUtil") public interface TimestampUtil
An instance of the Sitevision class implementing this interface can be obtained via Utils.getTimestampUtil()
.
See Utils
for how to obtain an instance of the Utils
interface.
Modifier and Type | Method and Description |
---|---|
String |
format(long aTimestamp,
String aFormatPattern)
Formats a given timestamp.
|
String |
format(long aTimestamp,
String aFormatPattern,
Locale aLocale)
Formats a given timestamp using a specified Locale.
|
String |
formatCurrent(String aFormatPattern)
Formats current timestamp.
|
String |
formatCurrent(String aFormatPattern,
Locale aLocale)
Formats current timestamp using a specified Locale.
|
long |
fromCalendar(Calendar aCalendar)
Converts a Calendar to a timestamp.
|
long |
fromDate(Date aDate)
Converts a Date to a timestamp.
|
long |
fromInstant(Instant aInstant)
Converts a Instant to a timestamp.
|
long |
fromLocalDateTime(LocalDateTime aLocalDateTime)
Converts a LocalDateTime to a timestamp (using the system default ZoneId).
|
long |
getTimestamp()
Returns current timestamp.
|
Calendar |
toCalendar(long aTimestamp)
Converts a timestamp to a Calendar.
|
Date |
toDate(long aTimestamp)
Converts a timestamp to a Date.
|
Instant |
toInstant(long aTimestamp)
Converts a timestamp to a Instant.
|
LocalDateTime |
toLocalDateTime(long aTimestamp)
Converts a timestamp to a LocalDateTime (using the system default ZoneId).
|
long getTimestamp()
String formatCurrent(String aFormatPattern)
aFormatPattern
- a date to string pattern according to SimpleDateFormat.PortletContextUtil.getCurrentLocale()
. If aLocale can not be resolved Locale.ENGLISH is used.
If aFormatPattern is not valid current timestamp is returned as String.String formatCurrent(String aFormatPattern, Locale aLocale)
aFormatPattern
- a date to string pattern according to SimpleDateFormat.aLocale
- a locale. If aLocale is null the current locale (as of
PortletContextUtil.getCurrentLocale()
) will be used. If aLocale can not be resolved
Locale.ENGLISH will be used.String format(long aTimestamp, String aFormatPattern)
aTimestamp
- a timestamp.aFormatPattern
- a date to string pattern according to SimpleDateFormat.PortletContextUtil.getCurrentLocale()
. If aLocale can not be resolved Locale.ENGLISH is used.
If aTimestamp is negative or aFormatPattern is not valid the given timestamp is returned as String.String format(long aTimestamp, String aFormatPattern, Locale aLocale)
aTimestamp
- a timestamp.aFormatPattern
- a date to string pattern according to SimpleDateFormat.aLocale
- a locale. If aLocale is null the current locale (as of
PortletContextUtil.getCurrentLocale()
) will be used. If aLocale can not be resolved
Locale.ENGLISH will be used.Date toDate(long aTimestamp)
aTimestamp
- a timestamp.long fromDate(Date aDate)
aDate
- a Date.Calendar toCalendar(long aTimestamp)
aTimestamp
- a timestamp.long fromCalendar(Calendar aCalendar)
aCalendar
- a Calendar.Instant toInstant(long aTimestamp)
aTimestamp
- a timestamp.long fromInstant(Instant aInstant)
aInstant
- a Instant.LocalDateTime toLocalDateTime(long aTimestamp)
aTimestamp
- a timestamp.long fromLocalDateTime(LocalDateTime aLocalDateTime)
aLocalDateTime
- a Instant.Sitevision - Portal and Content Management Made Easy
Sitevision is an advanced Java enterprise portal product and a portlet container (JSR 286) that implements Java Content Repository (JSR 283).
Copyright© 2008-2022 Sitevision AB, all rights reserved.