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 getDayStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);/*from   w  ww  .  j av  a2  s  . com*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

static void timeStamp(String msg, PrintWriter pw) {
    Calendar cal = Calendar.getInstance();
    pw.printf("%s %tc\n", msg, cal);
}

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  w ww .  j a  v  a 2 s.c  o m
}

From source file:Main.java

public static String getCurrentMonth() {
    Calendar calendar = Calendar.getInstance();
    return ((Integer) (calendar.get(Calendar.MONTH) + 1)).toString();
}

From source file:Main.java

public static String getFlushYear() {
    Calendar cal = Calendar.getInstance();
    int i = cal.get(Calendar.YEAR);
    String s = Integer.toString(i);
    return s;//from  ww w.j  a v a2s.co m
}

From source file:Main.java

public static Calendar getNextStart() {
    Calendar cc = Calendar.getInstance();
    cc.roll(Calendar.HOUR, 1);/*w ww .  j  a v a 2 s  . co m*/
    cc.set(Calendar.MINUTE, 0);
    cc.set(Calendar.SECOND, 0);
    return cc;
}

From source file:Util.java

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

From source file:Main.java

public static boolean isNowBeforeSixAM() {
    Calendar today = Calendar.getInstance();
    return ((today.get(Calendar.HOUR_OF_DAY) < 6 && (today.get(Calendar.HOUR_OF_DAY) >= 0) ? true : false));
}

From source file:Main.java

public static final int getCurrentDayOfWeek() {

    return Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1;

}

From source file:Main.java

public static long getTimesStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);//from  w w  w  .  j  a  v  a 2 s .  c om
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}