Example usage for java.util Calendar set

List of usage examples for java.util Calendar set

Introduction

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

Prototype

public void set(int field, int value) 

Source Link

Document

Sets the given calendar field to the given value.

Usage

From source file:Main.java

public static long getTimeMillisAt(int hour, int minute) {
    Calendar today = Calendar.getInstance();
    today.set(Calendar.HOUR_OF_DAY, hour);
    today.set(Calendar.MINUTE, minute);
    return today.getTimeInMillis();
}

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);/*from  w  w  w.  j  av  a 2s .  c o  m*/
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    return c.getTimeInMillis();
}

From source file:Main.java

public static Date trim(Date date) {
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);/*from ww  w  . j  a  v  a 2s  .co m*/
    cal.set(HOUR_OF_DAY, 0);
    cal.set(MINUTE, 0);
    cal.set(SECOND, 0);
    cal.set(MILLISECOND, 0);
    return cal.getTime();
}

From source file:Main.java

static public Calendar getTimeFromInt(int hourOfDay, int minute) {
    Calendar c = Calendar.getInstance();

    c.set(Calendar.HOUR_OF_DAY, hourOfDay);
    c.set(Calendar.MINUTE, minute);

    return c;/*from  w w w.j a  va2  s  .co m*/
}

From source file:Main.java

public static int getdataCount(int year, int month) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month - 1);
    int count = cal.getActualMaximum(Calendar.DATE);
    return count;
}

From source file:Main.java

public static final long getValidTime(TimePicker timePicker) {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour().intValue());
    c.set(Calendar.MINUTE, timePicker.getCurrentMinute().intValue());

    return c.getTimeInMillis();
}

From source file:Main.java

public static int getCurrentMonthDay() {
    // calendar.getActualMaximum(Calendar.DAY_OF_MONTH),
    Calendar a = Calendar.getInstance();
    a.set(Calendar.DATE, 1);
    a.roll(Calendar.DATE, -1);//from   w  ww . j a  v  a 2  s . co m
    int maxDate = a.get(Calendar.DATE);
    return maxDate;
}

From source file:Main.java

public static int getDaysOfMonth(int year, int month) {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month - 1);
    int days = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
    return days;//ww w  .  j  a v a  2s.c o  m
}

From source file:Main.java

public static long getTimesNextStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 24);
    cal.set(Calendar.SECOND, 0);/*from  ww w.j  ava2  s  .c o  m*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getSmallHourTimestamp() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR, 0);
    cal.set(Calendar.MINUTE, 0);//from www .  java 2s  . c om
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}