List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static String getCurrentMonth() { Calendar calendar = Calendar.getInstance(); int nMonth = calendar.get(Calendar.MONTH) + 1; if (nMonth < 10) return "0" + Integer.toString(nMonth); else// w w w .j a v a 2s.com return Integer.toString(nMonth); }
From source file:Main.java
public static int dayFrom_CalendarLocal(Calendar c) { return dayFrom_Milliseconds(c.getTimeInMillis() + c.get(Calendar.ZONE_OFFSET)); }
From source file:Main.java
public static String getYear() { Calendar calendar = Calendar.getInstance(); return String.valueOf(calendar.get(Calendar.YEAR)); }
From source file:Main.java
static float getDatePlg() { Calendar c = new GregorianCalendar(); int y = c.get(Calendar.YEAR); int m = 1 + c.get(Calendar.MONTH); int d = c.get(Calendar.DAY_OF_MONTH); return getDatePlg(y, m, d); }
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 List<String> getAniosConsulta() { Calendar c = Calendar.getInstance(); int anio = c.get(Calendar.YEAR); List<String> anios = new LinkedList<String>(); int amount = anio + 6; for (int i = anio; i < amount; i++) { anios.add("" + anio--); }/*from ww w .j ava2s. c om*/ return anios; }
From source file:Main.java
public static LinkedList<String> getAniosVigencia() { Calendar c = Calendar.getInstance(); int anio = c.get(Calendar.YEAR); LinkedList<String> anios = new LinkedList<String>(); int amount = anio + 7; for (int i = anio; i < amount; i++) { anios.add("" + i); }//from ww w. j ava 2 s. c om return anios; }
From source file:Main.java
public static boolean isOver18(int year, int month, int day) { Calendar cal = Calendar.getInstance(); int months = (cal.get(Calendar.YEAR) - year) * 12; months += cal.get(Calendar.MONTH) - month; int age = months / 12; if (age < 18 || (age == 18 && day > cal.get(Calendar.DAY_OF_MONTH))) { return false; }/* w w w . ja v a 2s . c o m*/ return true; }
From source file:Main.java
public static String getCurrentDateString() { Calendar currentCalendar = Calendar.getInstance(); currentYear = currentCalendar.get(Calendar.YEAR); return dateFormat.format(currentCalendar.getTimeInMillis()); }
From source file:Main.java
public static Date getNearestFutureDateWithHour(int hourOfDay) { Calendar cal = Calendar.getInstance(); int hourOfDayNow = cal.get(Calendar.HOUR_OF_DAY); if (hourOfDayNow > hourOfDay) { cal.add(Calendar.DAY_OF_MONTH, 1); }//w w w.j av a 2 s .c o m cal.set(Calendar.HOUR, hourOfDay); return cal.getTime(); }