Example usage for java.util Date getSeconds

List of usage examples for java.util Date getSeconds

Introduction

In this page you can find the example usage for java.util Date getSeconds.

Prototype

@Deprecated
public int getSeconds() 

Source Link

Document

Returns the number of seconds past the minute represented by this date.

Usage

From source file:Main.java

public static String getXMLDateString() {
    Date date = new Date();
    // YYYY-MM-DDThh:mm:ss

    // Must be a simpler way to do this....
    String xmlDateFormat = "" + (date.getYear() + 1900);
    int month = (date.getMonth() + 1);
    String monthStr = fillZero(month);
    String dateStr = fillZero(date.getDate());
    xmlDateFormat = xmlDateFormat + "-" + monthStr;
    xmlDateFormat = xmlDateFormat + "-" + dateStr;
    xmlDateFormat = xmlDateFormat + "T" + fillZero(date.getHours());
    xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getMinutes());
    xmlDateFormat = xmlDateFormat + ":" + fillZero(date.getSeconds());

    return (xmlDateFormat);
}

From source file:org.nuclos.common2.DateUtils.java

/**
 * @param date is not altered.//from w w w .j av  a  2  s  .c om
 * @return Is the given date pure?
 * @precondition date != null
 * @postcondition result --> date.getHours() == 0
 * @postcondition result --> date.getMinutes() == 0
 * @postcondition result --> date.getSeconds() == 0
 * @see   #getPureDate(Date)
 */
public static boolean isPure(Date date) {
    final boolean result = date.equals(getPureDate(date));
    assert !result || date.getHours() == 0;
    assert !result || date.getMinutes() == 0;
    assert !result || date.getSeconds() == 0;
    return result;
}

From source file:Main.java

static public void appendDateNode(Document owner, Element appendElement, String name, Date date) {
    Element dateElem = owner.createElement(name);
    appendElement.appendChild(dateElem);
    appendSingleValElement(owner, dateElem, "month", Integer.toString(date.getMonth() + 1));
    appendSingleValElement(owner, dateElem, "day", Integer.toString(date.getDate()));
    appendSingleValElement(owner, dateElem, "year", Integer.toString(date.getYear() + 1900));
    appendSingleValElement(owner, dateElem, "hour", Integer.toString(date.getHours()));
    appendSingleValElement(owner, dateElem, "minute", Integer.toString(date.getMinutes()));
    appendSingleValElement(owner, dateElem, "second", Integer.toString(date.getSeconds()));
}

From source file:com.fluidops.iwb.api.ValueResolver.java

/**
 * Converts a system date like '2011-03-31T19:54:33' to user-readable date.
 * If the input is not a valid system date, the value is returned as is.
 * /*w  w w. j  a  va  2s  . c  o m*/
 * @param sysdate
 * @return
 */
public static String resolveSysDate(String sysdate) {
    Date d = ReadDataManagerImpl.ISOliteralToDate(sysdate);
    if (d == null)
        return StringEscapeUtils.escapeHtml(sysdate);

    DateFormat df = null;
    if (d.getHours() == 0 && d.getMinutes() == 0 && d.getSeconds() == 0)
        df = new SimpleDateFormat("MMMMM dd, yyyy");
    else
        df = new SimpleDateFormat("MMMMM dd, yyyy, HH:mm:ss");
    return df.format(d);
}

From source file:com.eryansky.common.utils.StringUtils.java

/**
 * ???/*from w w w.  java 2  s .  co m*/
 * 
 * @param time
 * @return
 */
@SuppressWarnings("deprecation")
public static String processTime(Long time) {
    long oneDay = 24 * 60 * 60 * 1000;
    Date now = new Date();
    Date orginalTime = new Date(time);
    long nowDay = now.getTime() - (now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()) * 1000;
    long yesterday = nowDay - oneDay;
    String nowHourAndMinute = toDoubleDigit(orginalTime.getHours()) + ":"
            + toDoubleDigit(orginalTime.getMinutes());
    if (time >= now.getTime()) {
        return "";
    } else if ((now.getTime() - time) < (60 * 1000)) {
        return (now.getTime() - time) / 1000 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (24 * 60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 / 60 + "?? " + nowHourAndMinute + " ";
    } else if (time >= nowDay) {
        return " " + nowHourAndMinute;
    } else if (time >= yesterday) {
        return " " + nowHourAndMinute;
    } else {
        return toDoubleDigit(orginalTime.getMonth()) + "-" + toDoubleDigit(orginalTime.getDate()) + " "
                + nowHourAndMinute + ":" + toDoubleDigit(orginalTime.getSeconds());
    }
}

From source file:DateUtil.java

/**
  * Checks the second, hour, month, day, month and year are equal.
  *//*from   w w w  .  j a v a 2  s  .  c  o m*/
public static boolean dateTimeEquals(java.util.Date d1, java.util.Date d2) {
    if (d1 == null || d2 == null)
        return false;

    return d1.getDate() == d2.getDate() && d1.getMonth() == d2.getMonth() && d1.getYear() == d2.getYear()
            && d1.getHours() == d2.getHours() && d1.getMinutes() == d2.getMinutes()
            && d1.getSeconds() == d2.getSeconds();
}

From source file:org.nuclos.common2.DateUtils.java

/**
 * @param date is not changed by this method. May be <code>null</code>.
 * @return the pure date (aka "day", that is the date without time of day) of the given Date object (if any).
 * @postcondition date != null <--> result != null
 * @postcondition date != null --> result.getHours() == 0
 * @postcondition date != null --> result.getMinutes() == 0
 * @postcondition date != null --> result.getSeconds() == 0
 * @todo consider calling this method getDay(). On the other hand, that name could be confused with Date.getDay()...
 *//* w w w  .j a v a 2 s .c o m*/
public static Date getPureDate(Date date) {
    final Date result = (date == null) ? null
            : org.apache.commons.lang.time.DateUtils.truncate(date, Calendar.DATE);
    assert (date != null) == (result != null);

    assert (date == null) || result.getHours() == 0;
    assert (date == null) || result.getMinutes() == 0;
    assert (date == null) || result.getSeconds() == 0;
    return result;
}

From source file:org.nerve.utils.StringUtils.java

/**
 * ???/*from  w  w  w  . j  a va2 s .  c o  m*/
 *
 * @param time      
 * @return
 */
public static String processTime(Long time) {
    long oneDay = 24 * 60 * 60 * 1000;
    Date now = new Date();
    Date orginalTime = new Date(time);
    long nowDay = now.getTime() - (now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()) * 1000;
    long yesterday = nowDay - oneDay;
    String nowHourAndMinute = toDoubleDigit(orginalTime.getHours()) + ":"
            + toDoubleDigit(orginalTime.getMinutes());
    if (time >= now.getTime()) {
        return "";
    } else if ((now.getTime() - time) < (60 * 1000)) {
        return (now.getTime() - time) / 1000 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (24 * 60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 / 60 + "?? " + nowHourAndMinute + " ";
    } else if (time >= nowDay) {
        return " " + nowHourAndMinute;
    } else if (time >= yesterday) {
        return " " + nowHourAndMinute;
    } else {
        return toDoubleDigit(orginalTime.getMonth()) + "-" + toDoubleDigit(orginalTime.getDate()) + " "
                + nowHourAndMinute + ":" + toDoubleDigit(orginalTime.getSeconds());
    }
}

From source file:org.infoscoop.request.filter.rss.RssHandler.java

/**
 * Return the date whose form is "yyyy/MM/dd HH:mm:ss" -> obsolute
 * javascript Date :An argument form of the object instance.
 * Return the date whose form is "yyyy,MM,dd,HH,mm,ss".
 * /*ww w  .ja  va 2s  .  com*/
 * @param date
 * @return
 */
public static String getFullDate(Date date) {
    if (date == null) {
        return null;
    }

    try {
        //         return formatFullDate.format(date);
        return (date.getYear() + 1900) + "," + date.getMonth() + "," + date.getDate() + "," + date.getHours()
                + "," + date.getMinutes() + "," + date.getSeconds();
    } catch (IllegalArgumentException e1) {
        return null;
    }
}

From source file:com.opendesign.utils.Day.java

@SuppressWarnings("deprecation")
public static String addSeconds(String dateTime, int seconds) {

    Date date = getDateWithTyphoonFormatString(dateTime);
    date.setSeconds(date.getSeconds() + seconds);

    return Day.toStringAsyyyyMMddHHmmss(date.getTime());

}