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

public static long intID() {
    Calendar c = Calendar.getInstance();

    int dia = c.get(Calendar.DAY_OF_MONTH);
    int ano = c.get(Calendar.YEAR) - 2010;
    int mes = c.get(Calendar.MONTH) + 1;

    int hora = c.get(Calendar.HOUR_OF_DAY);
    int minuto = c.get(Calendar.MINUTE);
    int segundo = c.get(Calendar.SECOND);
    int milisec = c.get(Calendar.MILLISECOND);

    return Long.parseLong("" + ano + mes + dia + hora + minuto + segundo + milisec);
}

From source file:Main.java

public static String getDay() {
    return Calendar.getInstance().getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.US);
}

From source file:Main.java

public static int getTodayPlus() {
    Calendar cd = Calendar.getInstance();

    int ret = cd.get(Calendar.DAY_OF_WEEK);
    if (ret == Calendar.SUNDAY)
        return 6;
    ///*from   www .j  a v  a  2  s.  c  o m*/
    return cd.get(Calendar.DAY_OF_WEEK) - 2;// - 1
}

From source file:Main.java

public static long getTimesMonthStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
    return cal.getTimeInMillis();
}

From source file:Main.java

public static Date getToday() {
    return Calendar.getInstance().getTime();
}

From source file:Main.java

public static int getCurrentTimeStamp() {
    Calendar now = Calendar.getInstance();
    int hour = now.get(Calendar.HOUR_OF_DAY);
    int minute = now.get(Calendar.MINUTE);
    return 60 * hour + minute;
}

From source file:Main.java

public static String getCurrentTime() {
    Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH) + 1;
    int day = c.get(Calendar.DAY_OF_MONTH);
    String time = year + "-" + month + "-" + day;
    return time;//www.jav  a2s  . co  m
}

From source file:Main.java

public static Date getNow() {
    return Calendar.getInstance().getTime();
}

From source file:Main.java

public static String getNow() {
    final Calendar calendar = Calendar.getInstance();
    return calendar.get(Calendar.YEAR) + "/" + calendar.get(Calendar.MONTH) + 1 + "/"
            + calendar.get(Calendar.DAY_OF_MONTH) + "/" + " " + calendar.get(Calendar.HOUR_OF_DAY) + ":"
            + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND);
}

From source file:Main.java

public static boolean checkFirstDayOfMonth() {
    Calendar c = Calendar.getInstance();
    return (c.get(Calendar.DATE) == 1);
}