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 Long getToday() {
    Calendar today = Calendar.getInstance();
    today.setTimeZone(TimeZone.getDefault());

    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.HOUR_OF_DAY, 1);
    today.set(Calendar.MILLISECOND, 0);

    // FOR DEBUG//from w  ww .  j a  v  a2s.co  m
    //today.set(Calendar.DAY_OF_YEAR, today.get(Calendar.DAY_OF_YEAR) + 1);

    return today.getTimeInMillis();
}

From source file:Main.java

public static Calendar tomorrow() {
    Calendar tomorrow = new GregorianCalendar();
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 0);
    tomorrow.set(Calendar.MILLISECOND, 0);
    tomorrow.add(Calendar.DAY_OF_MONTH, 1);
    return tomorrow;
}

From source file:Main.java

public static Date hourRoundPlusHour(Date date, int n) {
    Calendar calendar = Calendar.getInstance();

    calendar.setTime(date);//from w  w  w. j a  va 2s .c  o  m
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MINUTE, 0);

    calendar.add(Calendar.HOUR_OF_DAY, n);

    return calendar.getTime();
}

From source file:Main.java

public static Date dayBegin(Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);/*from   w  w w .ja  v  a2s .c  o m*/
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    return c.getTime();
}

From source file:Main.java

public static Calendar getFirstDayOfWeek() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);//from w  ww  .jav a  2 s .c o  m
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal;
}

From source file:Main.java

/**
 * keep year, month & day of calendar
 *
 * @param c calendar to be clear/*from  w  ww.j a  v  a 2s . c  o  m*/
 */
public static void clearCalendarOffset(Calendar c) {
    c.set(Calendar.MILLISECOND, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.HOUR_OF_DAY, 0);
}

From source file:Main.java

static private Calendar getCalendarAlarmTime(int hour, int minute) {
    Calendar alarmTime = Calendar.getInstance();

    alarmTime.set(Calendar.HOUR_OF_DAY, hour);
    alarmTime.set(Calendar.MINUTE, minute);
    alarmTime.set(Calendar.SECOND, 0);

    return alarmTime;

}

From source file:Main.java

public static long getDayInUTC(long time) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);/*from   ww  w  .  j  a  v  a  2  s  .c  om*/
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.setTimeZone(TimeZone.getTimeZone("UTC"));
    return cal.getTimeInMillis();
}

From source file:Main.java

public static void timeStamp(String tag) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    System.out.println("time stamp - " + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND)
            + ":" + calendar.get(Calendar.MILLISECOND) + " -- " + tag);
}

From source file:Main.java

public static Calendar getExpireTime(int expireSeconds) {
    Calendar c = Calendar.getInstance();
    c.add(Calendar.SECOND, expireSeconds);
    return c;/* w ww. j av  a 2s .  c  o  m*/
}