List of usage examples for java.util Calendar getInstance
public static Calendar getInstance()
From source file:Main.java
public static Calendar getEndOfDate(long time) { Calendar ret = Calendar.getInstance(); ret.setTimeInMillis(time);//from w w w . ja va2 s. c om ret.set(Calendar.HOUR_OF_DAY, 23); ret.set(Calendar.MINUTE, 59); ret.set(Calendar.SECOND, 59); ret.set(Calendar.MILLISECOND, 999); return ret; }
From source file:Main.java
public static int getMonthDayNumber(int offset) { Calendar calendar = Calendar.getInstance(); if (offset != 0) calendar.add(Calendar.MONTH, offset); return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); }
From source file:Main.java
public static int getCurrentYear() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); return c.get(Calendar.YEAR); }
From source file:Main.java
public static int getMinutes() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); int minute = c.get(Calendar.MINUTE); return minute; }
From source file:Main.java
public static Date getCurrentDate() { Calendar c = Calendar.getInstance(); return c.getTime(); }
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 Calendar fromMilisecond(long miliseconds) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(miliseconds);/* w w w . jav a 2 s . c om*/ return cal; }
From source file:Main.java
public static String getDateForFile() { Calendar currentTime = Calendar.getInstance(); int month = currentTime.get(2); int date = currentTime.get(5); int year = currentTime.get(1); int hour = currentTime.get(11); int minute = currentTime.get(12); int second = currentTime.get(13); String result = year + "." + month + "." + date + "/" + hour + ":" + minute + ":" + second; return result; }
From source file:Main.java
public static int getMonth(int year, int week) { Calendar calendar = Calendar.getInstance(); calendar.clear();//from www. j a v a 2s. com calendar.set(Calendar.YEAR, year); calendar.set(Calendar.WEEK_OF_YEAR, week); return calendar.get(Calendar.MONTH) + 1; }
From source file:Main.java
public static int getDayNumOfMonth(int y, int m) { Calendar calendar = Calendar.getInstance(); calendar.set(y, m - 1, 1);/*from w w w .j a va 2 s . c o m*/ int dateNumber = calendar.getActualMaximum(Calendar.DATE); return dateNumber; }