List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
static String getDate() { Calendar calendar = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("dd MMMM yyyy"); return df.format(calendar.getTime()); }
From source file:Main.java
public static String currentDate() { Calendar c = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); }
From source file:Main.java
static public Calendar getTimeFromInt(int hourOfDay, int minute) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, hourOfDay); c.set(Calendar.MINUTE, minute); return c;/*from ww w .j a v a2 s.co m*/ }
From source file:Main.java
public static int getAnioVigenciaPosition(String vigenciaAnio) { Calendar c = Calendar.getInstance(); int anio = c.get(Calendar.YEAR); String anioInicial = String.valueOf(anio).substring(2, 4); int inicial = Integer.parseInt(anioInicial); int fin = Integer.parseInt(vigenciaAnio); return fin - inicial; }
From source file:Main.java
public static int getWeekOfDate(Date dt) { Calendar cal = Calendar.getInstance(); cal.setTime(dt);//www . jav a2s.c o m int w = cal.get(Calendar.DAY_OF_WEEK) - 1; return w < 0 ? 0 : w; }
From source file:Main.java
public static String getTodayYYYYMMDD() { Calendar calendar = Calendar.getInstance(); StringBuffer sbDate = new StringBuffer(); int nYear, nMonth, nDay; nYear = calendar.get(Calendar.YEAR); nMonth = calendar.get(Calendar.MONTH) + 1; nDay = calendar.get(Calendar.DAY_OF_MONTH); sbDate.append(nYear);//ww w.j av a2 s.c o m if (nMonth < 10) sbDate.append("0"); sbDate.append(nMonth); if (nDay < 10) sbDate.append("0"); sbDate.append(nDay); return sbDate.toString(); }
From source file:Main.java
public static String yesterday() { Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, -1);// ww w . j a v a 2 s .c o m SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); }
From source file:Main.java
public static String getTimezone() { return Calendar.getInstance().getTimeZone().getID(); }
From source file:Main.java
public static Date getLastDayOfYear() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); return calendar.getTime(); }
From source file:Main.java
public static java.util.Date getDateEnd(java.util.Date d) { Calendar c = Calendar.getInstance(); c.clear();//www . j av a 2 s .c o m Calendar co = Calendar.getInstance(); co.setTime(d); c.set(Calendar.DAY_OF_MONTH, co.get(Calendar.DAY_OF_MONTH)); c.set(Calendar.MONTH, co.get(Calendar.MONTH)); c.set(Calendar.YEAR, co.get(Calendar.YEAR)); c.add(Calendar.DAY_OF_MONTH, 1); c.add(Calendar.MILLISECOND, -1); return c.getTime(); }