Java Utililty Methods Second Format

List of utility methods to do Second Format

Description

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

Method

intgetSeconds(long time)
get Seconds
return Integer.valueOf(SECOND_FORMATTER.format(new Date(time)));
DecimalFormatgetSecondsFormatter()
get Seconds Formatter
return secondsFormatter.get();
intgetSecondsSince(String rfc1123Date)
get Seconds Since
Date reference = parse(rfc1123Date);
Date now = new Date();
return (int) ((now.getTime() - reference.getTime()) / 1000L);
StringgetStringFromNanoSeconds(final long nanoSeconds, final long format)
get String From Nano Seconds
if (nanoSeconds < 0) {
    throw new IllegalArgumentException("Nanoseconds must not be less than 0");
String outputString = "";
return outputString;
StringgetThisSecondTime()
get This Second Time
Calendar calendar = Calendar.getInstance();
Date currentTime = calendar.getTime();
SimpleDateFormat formatter = new SimpleDateFormat("yyMMddHHmmss");
return formatter.format(currentTime);
IntegergetTimeSecondInteger(Date date)
get Time Second Integer
try {
    SimpleDateFormat formater = new SimpleDateFormat("HHmmss");
    return Integer.valueOf(formater.format(date));
} catch (Exception e) {
    return null;
StringgetToSecond()
HH:mm:ss
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
Date logonDate = Calendar.getInstance().getTime();
return sdf.format(logonDate);
longhumanDateToSeconds(String date)
human Date To Seconds
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(CURRENT_TIME_ZONE);
Date d = sdf.parse(date);
return d.getTime() / 1000;
StringparseLongToString(long millsSeconds)
parse Long To String
SimpleDateFormat df = new SimpleDateFormat(yyyyMMddHH);
Date date = new Date(millsSeconds);
return df.format(date);
DateparseNoSecondFormat(String sDate)
yyyy-MM-dd HH:mm
DateFormat dateFormat = new SimpleDateFormat(noSecondFormat);
if ((sDate == null) || (sDate.length() < noSecondFormat.length())) {
    throw new ParseException("length too little", 0);
return dateFormat.parse(sDate);