Java Utililty Methods Timestamp Field

List of utility methods to do Timestamp Field

Description

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

Method

java.sql.TimestampgetSqlTimestampFromMicrosSinceEpoch(long timestamp)
get Sql Timestamp From Micros Since Epoch
java.sql.Timestamp result;
if (timestamp >= 0) {
    result = new java.sql.Timestamp(timestamp / 1000);
    result.setNanos(((int) (timestamp % 1000000)) * 1000);
} else {
    result = new java.sql.Timestamp((timestamp / 1000000 - 1) * 1000);
    int remaining = (int) (timestamp % 1000000);
    result.setNanos((remaining + 1000000) * 1000);
...
TimestampgetSqlTimestampFromShortDate(String date)
get Sql Timestamp From Short Date
Date _date = getShortDate(date);
int _year = Integer.parseInt(getYear(_date));
int _month = Integer.parseInt(getMonth(_date)) - 1;
int _day = Integer.parseInt(getDay(_date));
Calendar _cal = Calendar.getInstance();
Timestamp _value = new Timestamp(_cal.getTimeInMillis());
try {
    _cal.set(_year, _month, _day);
...
StringgetStamp(Timestamp timestamp)
get Stamp
String stamp = timestamp.toString();
stamp = stamp.replaceAll("-", "");
stamp = stamp.replaceAll(":", "");
stamp = stamp.replaceAll("\\.", "");
stamp = stamp.replaceAll(" ", "");
return stamp;
TimestampgetStringToTimestamp(String str)
get String To Timestamp
Timestamp ts = Timestamp.valueOf(str);
return ts;
TimestampgetstrTimestamp(String datetime)
getstr Timestamp
java.util.Date bb = new java.util.Date(datetime);
if (bb != null) {
    return new Timestamp(bb.getTime());
} else {
    return null;
java.sql.TimestampgetSysDateTimestamp()
get Sys Date Timestamp
return new java.sql.Timestamp(System.currentTimeMillis());
TimestampgetSystemTimestamp()
Returns the current timestamp.
return new Timestamp(System.currentTimeMillis());
TimestampgetSystemTimestamp()
get System Timestamp
return new Timestamp(getSystemTime());
TimestampgetWeekEnd(Timestamp stamp, TimeZone timeZone, Locale locale)
get Week End
Timestamp weekStart = getWeekStart(stamp, timeZone, locale);
Calendar tempCal = toCalendar(weekStart, timeZone, locale);
tempCal.add(Calendar.DAY_OF_MONTH, 6);
return getDayEnd(new Timestamp(tempCal.getTimeInMillis()), timeZone, locale);
TimestampgetWeekEnd(Timestamp stamp, TimeZone timeZone, Locale locale)
get Week End
Calendar tempCal = toCalendar(stamp, timeZone, locale);
tempCal.set(tempCal.get(Calendar.YEAR), tempCal.get(Calendar.MONTH), tempCal.get(Calendar.DAY_OF_MONTH), 0,
        0, 0);
tempCal.add(Calendar.WEEK_OF_MONTH, 1);
tempCal.set(Calendar.DAY_OF_WEEK, tempCal.getFirstDayOfWeek());
tempCal.add(Calendar.SECOND, -1);
Timestamp retStamp = new Timestamp(tempCal.getTimeInMillis());
retStamp.setNanos(999999999);
...