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:Main.java

public static String getSecond() {
    Calendar c = Calendar.getInstance();
    c.setTime(new Date());
    int second = c.get(Calendar.SECOND);
    return Integer.toString(second);
}

From source file:Main.java

public static Calendar setEndOfDate(Calendar calendar) {
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);
    return calendar;
}

From source file:Main.java

public static long today9am() {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 9);
    c.set(Calendar.MINUTE, 0);//w w w . j  a  v  a2  s  .com
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    return c.getTimeInMillis();
}

From source file:Main.java

public static Calendar getCalendarClearMinuteByNow() {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    return calendar;
}

From source file:Main.java

public static Calendar getNextStart() {
    Calendar cc = Calendar.getInstance();
    cc.roll(Calendar.HOUR, 1);/*from  w  w  w  .j  a v  a2 s .  c o m*/
    cc.set(Calendar.MINUTE, 0);
    cc.set(Calendar.SECOND, 0);
    return cc;
}

From source file:Main.java

public static Calendar clearTime(Calendar calendar) {
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    return calendar;
}

From source file:Main.java

public static long getSmallHourTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR, 0);/*from w  w  w  .j  av a  2  s  . co  m*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static void toBeginOfDay(Calendar cal) {
    cal.set(Calendar.HOUR_OF_DAY, 0); // ! clear would not reset the hour of day !
    cal.clear(Calendar.MINUTE);/*from   ww w .  j  a v  a  2  s. c o m*/
    cal.clear(Calendar.SECOND);
    cal.clear(Calendar.MILLISECOND);
}

From source file:Main.java

public static Calendar clearToDate(Calendar calendar) {
    return clear(calendar, Calendar.HOUR, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
            Calendar.MILLISECOND);
}

From source file:Main.java

public static long getTimesmorning() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MINUTE, 0);//  ww  w.ja  v  a  2 s .  c o m
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}