Java Utililty Methods Timestamp Format

List of utility methods to do Timestamp Format

Description

The list of methods to do Timestamp Format are organized into topic(s).

Method

intcompareTimstampStr(String timestamp1, String timestamp2, String format)
compare Timstamp Str
int result = 10;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
long temp = 10L;
try {
    Date date1 = simpleDateFormat.parse(timestamp1);
    Date date2 = simpleDateFormat.parse(timestamp2);
    temp = date1.getTime() - date2.getTime();
} catch (ParseException e) {
...
DatedecodeFileTimestamp(File file, Pattern filenamePattern, DateFormat dateFormat)
Decode a file's timestamp given a pattern to extract the timestamp from its name (in group 1) and a dateFormat to parse the date.
Date result = null;
final String name = file.getName();
final Matcher m = filenamePattern.matcher(name);
if (m.matches()) {
    try {
        result = dateFormat.parse(m.group(1));
    } catch (ParseException e) {
return result;
Stringformat(BigDecimal data)
format
if (data == null) {
    return null;
DecimalFormat format = new DecimalFormat(PATTERN);
return format.format(data);
Stringformat(Date aTs_Datetime)
format
return format(aTs_Datetime, DATE_PATTERN_DEFAULT);
Stringformat(Date date)
format
return format(date, PATTERN_CLASSICAL);
Stringformat(Date date, String format)
format
SimpleDateFormat sf = new SimpleDateFormat(format);
sf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
return sf.format(date);
Stringformat(Date time, String pattern)
format
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(time);
Stringformat(Date timestamp)
Formats the given timestamp according OGC standard
SimpleDateFormat formatter = new SimpleDateFormat(zuluFormat);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return formatter.format(timestamp);
Stringformat(Date timestamp, String format)
format
SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.format(timestamp);
StringFormat(DateFormat format, Timestamp time)
Format
synchronized (format) {
    String t = "";
    try {
        t = format.format(time);
    } catch (Exception e) {
        return t;
    return t;
...