List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
@NonNull public static String getTime() { 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 int getTodayPlus() { Calendar cd = Calendar.getInstance(); int ret = cd.get(Calendar.DAY_OF_WEEK); if (ret == Calendar.SUNDAY) return 6; ///*from ww w . ja v a2 s. c o m*/ return cd.get(Calendar.DAY_OF_WEEK) - 2;// - 1 }
From source file:Main.java
public static String getCurrentDateString() { Calendar calendar = Calendar.getInstance(); return calendar.get(Calendar.YEAR) + "-" + String.format("%02d", (calendar.get(Calendar.MONTH) + 1)) + "-" + String.format("%02d", calendar.get(Calendar.DATE)); }
From source file:Main.java
public static String dataHoje() { Integer dia, mes, ano;/*w ww . j a v a 2 s . c om*/ Calendar calendario = Calendar.getInstance(); dia = calendario.get(Calendar.DAY_OF_MONTH); mes = calendario.get(Calendar.MONTH); ano = calendario.get(Calendar.YEAR); return dia + "/" + (mes + 1) + "/" + ano; }
From source file:Main.java
public static String[] getListOfCarYears() { String years = ""; Calendar cal = Calendar.getInstance(); for (int i = cal.get(Calendar.YEAR) + 1; i > cal.get(Calendar.YEAR) - 25; i--) { years += i + ","; }/*from w w w.j a v a 2 s. co m*/ return years.substring(0, years.length() - 1).split(","); }
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 String getCurrentDayOfMonth() { Calendar calendar = Calendar.getInstance(); return ((Integer) calendar.get(Calendar.DAY_OF_MONTH)).toString(); }
From source file:Main.java
private static boolean workingHours(Calendar calendar) { int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); if (hour < 8 || hour > 17) { return false; }/* w w w .j a v a 2 s . co m*/ if (hour == 17 && minute > 50) { return false; } return true; }
From source file:Main.java
public static String year() { Calendar cal = Calendar.getInstance(); return String.valueOf(cal.get(Calendar.YEAR)); }
From source file:Main.java
public static String getRemoteDir() { Calendar calendar = Calendar.getInstance(); String str = calendar.get(Calendar.YEAR) + "_" + (calendar.get(Calendar.MONTH) + 1) + "_" + calendar.get(Calendar.DAY_OF_MONTH); return str;//from w ww.j a v a 2 s.c om }