Example usage for java.util Calendar getInstance

List of usage examples for java.util Calendar getInstance

Introduction

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

Prototype

public static Calendar getInstance() 

Source Link

Document

Gets a calendar using the default time zone and locale.

Usage

From source file:Main.java

private static Date get6DaysAgo() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.DATE, -6);

    return calendar.getTime();
}

From source file:Main.java

private static Boolean isThisDayOfMonth(Calendar calendar) {
    Calendar nowCalendar = Calendar.getInstance();
    return calendar.get(Calendar.DAY_OF_MONTH) == nowCalendar.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

public static Calendar getCalenar() {
    return Calendar.getInstance();
}

From source file:Main.java

public static int getIsFristWeek() {
    Calendar cal = Calendar.getInstance();
    int date = cal.get(Calendar.DAY_OF_WEEK);
    Log.e("WeekDay", "" + date);
    return date;/*  www. ja  va2  s.c  o m*/
}

From source file:Main.java

private static Date get2MinsAgo() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.MINUTE, -2);

    return calendar.getTime();
}

From source file:Main.java

public static long getTimeLong(int year, int month, int day) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(year, month, day);/*w w w .  ja  va2 s  .c om*/
    return calendar.getTimeInMillis();
}

From source file:Main.java

public static int getWeekOfFirstDay(int year, int month) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    return calendar.get(Calendar.DAY_OF_WEEK);
}

From source file:Main.java

private static Date get3HoursAgo() {
    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.HOUR, -3);

    return calendar.getTime();
}

From source file:Main.java

public static int getDay() {
    Calendar now = Calendar.getInstance();
    return now.get(Calendar.DAY_OF_MONTH);
}

From source file:Main.java

private static Calendar add(long time, int val, int field) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(time);//from  w ww  . j  a v  a 2  s  .com

    if (field == 666) {
        c.add(Calendar.MONTH, val * 3);
    } else {
        c.add(field, val);
    }
    return c;
}