List of usage examples for java.util Calendar get
public int get(int field)
From source file:Main.java
public static int getYear() { return Calendar.getInstance().get(Calendar.YEAR); }
From source file:Main.java
public static int getDayOFYear(String date) { try {/*from w ww. j a v a 2 s . co m*/ Date parse = yearFormat.parse(date); Calendar instance = Calendar.getInstance(); instance.setTime(parse); return instance.get(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static int getHour() { return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); }
From source file:Main.java
public static int getMonth() { return Calendar.getInstance().get(Calendar.MONTH) + 1; }
From source file:Main.java
public static String dateGraphLabelParser(long epoch) { Date date = new Date(epoch); Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from ww w.ja v a2 s . c om*/ return String.format("%d/%d/%d", cal.get(Calendar.MONTH) + 1, cal.get(Calendar.DAY_OF_MONTH), cal.get(Calendar.YEAR)); }
From source file:Main.java
public static int getMonth() { return Calendar.getInstance().get(Calendar.MONTH); }
From source file:Main.java
/** * @param date/* w ww.jav a 2s . c om*/ * @return */ public static String encodeTime(Date date) { StringBuilder result = new StringBuilder("T_"); Calendar cal = Calendar.getInstance(); cal.setTime(date); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int day = cal.get(Calendar.DAY_OF_MONTH); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); int second = cal.get(Calendar.SECOND); //yyyy-MM-DD'T'kk:mm:ss result.append(year).append("-").append((month < 10) ? "0" : "").append(month).append("-") .append((day < 10) ? "0" : "").append(day).append("T").append((hour < 10) ? "0" : "").append(hour) .append(":").append((minute < 10) ? "0" : "").append(minute).append(":") .append((second < 10) ? "0" : "").append(second); return result.toString(); }
From source file:Main.java
public static String getDate() { return Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + " "; }
From source file:Main.java
public static int[] getStartEndDay(Date[] startEnd) { int[] startEndDay = new int[2]; Calendar calendar = Calendar.getInstance(); calendar.setTime(startEnd[0]);/*from ww w . j a v a 2 s. co m*/ startEndDay[0] = calendar.get(Calendar.DAY_OF_MONTH); calendar.setTime(startEnd[1]); startEndDay[1] = calendar.get(Calendar.DAY_OF_MONTH); return startEndDay; }
From source file:Main.java
public static int getMinute() { return Calendar.getInstance().get(Calendar.MINUTE); }