Example usage for java.util Calendar SECOND

List of usage examples for java.util Calendar SECOND

Introduction

In this page you can find the example usage for java.util Calendar SECOND.

Prototype

int SECOND

To view the source code for java.util Calendar SECOND.

Click Source Link

Document

Field number for get and set indicating the second within the minute.

Usage

From source file:net.kamhon.ieagle.util.DateUtil.java

/**
 * add time to date./*from   ww w  .  jav a2s .c  o  m*/
 * 
 * @param date
 * @param time
 * @return
 */
public static Date addTime(Date date, Time time) {
    Calendar calendar = setTime(date);
    calendar.add(Calendar.SECOND, time.getSecond());
    calendar.add(Calendar.MINUTE, time.getMinute());
    calendar.add(Calendar.HOUR_OF_DAY, time.getHour());
    return calendar.getTime();
}

From source file:com.adobe.acs.commons.http.headers.impl.DailyExpiresHeaderFilterTest.java

@Test
public void testAdjustExpiresPast() throws Exception {

    Calendar actual = Calendar.getInstance();
    actual.set(Calendar.SECOND, 0);
    actual.set(Calendar.MILLISECOND, 0);

    Calendar expected = Calendar.getInstance();
    expected.setTime(actual.getTime());/*from  w  w w. j a v  a 2s .  c  o m*/
    expected.add(Calendar.DAY_OF_MONTH, 1);

    filter.adjustExpires(actual);

    assertTrue(DateUtils.isSameInstant(expected, actual));
}

From source file:com.qpark.eip.core.spring.statistics.impl.SysUserStatisticsChannelInvocationListener.java

/**
 * Get a {@link Date}, where hours, minutes, seconds and milliseconds are
 * set to 0./*from w w w . j av  a 2 s .co  m*/
 *
 * @return the {@link Date} and the corresponding log string.
 */
public static Calendar getRequestDate() {
    Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE);
    gc.set(Calendar.HOUR_OF_DAY, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    return gc;
}

From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsEraser.java

/**
 * Each day at 0:00 remove old out dated entries.
 *///from w  w w  .  j a  v  a  2  s . c  om
@Scheduled(cron = "0 0 0 * * *")
public void erase() {
    Calendar gc = new GregorianCalendar();
    gc.set(Calendar.HOUR_OF_DAY, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    gc.add(Calendar.WEEK_OF_YEAR, -1 * Math.abs(this.numberOfWeeksToKeepLogs));
    this.dao.eraseSystemUserLog(gc.getTime());
    this.dao.eraseApplicationUserLog(gc.getTime());
    this.dao.eraseFlowLogMessage(gc.getTime());
}

From source file:TimeUtil.java

public static String stringSecsFormat(long msecs) {
    GregorianCalendar cal = new GregorianCalendar();
    StringBuffer sBuf = new StringBuffer(11);

    cal.setTime(new Date(msecs));

    int hour = cal.get(Calendar.HOUR);

    if (hour == 0)
        hour = 12;/*from   ww w. j a  v a  2  s . c om*/

    if (hour < 10)
        sBuf.append(" ");

    sBuf.append(Integer.toString(hour));
    sBuf.append(":");

    int minute = cal.get(Calendar.MINUTE);

    if (minute < 10)
        sBuf.append("0");

    sBuf.append(Integer.toString(minute));
    sBuf.append(":");

    int secs = cal.get(Calendar.SECOND);

    if (secs < 10) {
        sBuf.append("0");
    }
    sBuf.append(Integer.toString(secs));

    sBuf.append(" ");
    sBuf.append(cal.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM");

    return (sBuf.toString());
}

From source file:ezbake.services.provenance.graph.Utils.java

public static ezbake.base.thrift.DateTime convertDate2DateTime(final java.util.Date theDate) {
    final Calendar cal = new GregorianCalendar();
    cal.setTime(theDate);//  www .j av a2 s .c  om

    // get calendar parts
    final int year = cal.get(Calendar.YEAR);
    final int month = cal.get(Calendar.MONTH) + 1;
    final int day = cal.get(Calendar.DAY_OF_MONTH);
    final int hour = cal.get(Calendar.HOUR_OF_DAY);
    final int minute = cal.get(Calendar.MINUTE);
    final int second = cal.get(Calendar.SECOND);
    int offsetMinutes = (cal.getTimeZone().getOffset(cal.getTimeInMillis())) / (1000 * 60);

    // set thrift DateTime propertiesd
    final ezbake.base.thrift.DateTime dt = new ezbake.base.thrift.DateTime();
    // Date
    final ezbake.base.thrift.Date date = new ezbake.base.thrift.Date();
    date.setMonth((short) month).setDay((short) day).setYear((short) year);
    dt.setDate(date);

    // Time with TimeZone
    final ezbake.base.thrift.Time t = new ezbake.base.thrift.Time();
    boolean afterUtc = offsetMinutes > 0;
    offsetMinutes = Math.abs(offsetMinutes);
    final ezbake.base.thrift.TimeZone tz = new ezbake.base.thrift.TimeZone((short) (offsetMinutes / 60),
            (short) (offsetMinutes % 60), afterUtc);
    t.setHour((short) hour).setMinute((short) minute).setSecond((short) second).setTz(tz);
    dt.setTime(t);

    return dt;
}

From source file:com.worldline.easycukes.rest.utils.DateHelper.java

/**
 * Used to convert date value in json date format
 *
 * @param value//w w  w. j  a  v  a2s  .c  o m
 * @return
 */
public static String convertDateToJsonFormat(@NonNull final Date value) {
    log.info("setting the date value " + value + " to format json");
    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(value);
    return calendar.get(Calendar.YEAR) + "-" + formatTo2Digit(calendar.get(Calendar.MONTH) + 1) + "-"
            + formatTo2Digit(calendar.get(Calendar.DAY_OF_MONTH)) + "T"
            + formatTo2Digit(calendar.get(Calendar.HOUR_OF_DAY)) + ":"
            + formatTo2Digit(calendar.get(Calendar.MINUTE)) + ":"
            + formatTo2Digit(calendar.get(Calendar.SECOND)) + ":" + calendar.get(Calendar.MILLISECOND) + "Z";
}

From source file:com.esofthead.mycollab.core.utils.DateTimeUtils.java

public static Date getCurrentDateWithoutMS() {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MINUTE, 0);
    return calendar.getTime();
}

From source file:com.microsoft.live.TestUtils.java

public static LiveConnectSession newMockLiveConnectSession() {
    LiveAuthClient authClient = TestUtils.newMockLiveAuthClient();
    LiveConnectSession session = new LiveConnectSession(authClient);
    session.setAccessToken("access_token");
    session.setAuthenticationToken("authentication_token");

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.SECOND, 3600);
    session.setExpiresIn(calendar.getTime());

    String[] scopes = { "scope" };
    session.setScopes(Arrays.asList(scopes));
    session.setRefreshToken("refresh_token");
    session.setTokenType("token_type");

    return session;
}

From source file:com.bstek.dorado.core.el.ExpressionUtilsObject.java

public java.util.Date getToday() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    return calendar.getTime();
}