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

private static void setStartOfMonthToCalendar(Calendar c) {
    c.set(Calendar.DAY_OF_MONTH, c.getMinimum(Calendar.DAY_OF_MONTH));
    setStartOfDayToCalendar(c);/*from  ww w  .j a  v a 2 s.co m*/
    Log.d("La Cuenta: ", "Min of Current Month: " + DateFormat.getInstance().format(c.getTime()));
}

From source file:Main.java

private static void setStartOfDayToCalendar(Calendar c) {
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);//from w w  w  .j a  v a  2s. c o m
    c.set(Calendar.SECOND, 0);
}

From source file:Main.java

public static Calendar dataFimMesAtual() {
    Calendar data = Calendar.getInstance();
    data.set(Calendar.DAY_OF_MONTH, data.getMaximum(Calendar.DAY_OF_MONTH));
    return data;/*from   ww  w . j  ava  2  s .c  o  m*/
}

From source file:Main.java

private static void setStartOfWeekToCalendar(Calendar c) {
    c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek());
    setStartOfDayToCalendar(c);/*from w  w w  . ja  va  2  s.  c  o m*/
    Log.d("La Cuenta: ", "Min of Current Week: " + DateFormat.getInstance().format(c.getTime()));
}

From source file:Main.java

public static void trimTimestamp(Calendar cal) {
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.MINUTE, 0);/*from   w  w w . j  a  v a2  s .c  om*/
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
}

From source file:Main.java

public static String firstDayOfMonth() {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.DAY_OF_MONTH, 1);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    return df.format(c.getTime());
}

From source file:Main.java

public static Date getTheEndOfDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);/* ww  w . ja v a  2 s  .c om*/
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    calendar.set(Calendar.MILLISECOND, 999);

    return calendar.getTime();
}

From source file:Main.java

public static Date getTheBeginingOfDate(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);/*from ww  w .  j av a  2 s  .c om*/
    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();
}

From source file:Main.java

public static void trunkDay(Calendar c) {
    c.set(Calendar.HOUR, 0);
    c.set(Calendar.MINUTE, 0);/* www  . j  a  v  a2  s .  co  m*/
    c.set(Calendar.SECOND, 0);
}

From source file:Main.java

private static Date weekDay(int week) {
    Calendar cal = calendar();
    cal.set(Calendar.DAY_OF_WEEK, week);
    return cal.getTime();
}