List of usage examples for java.util Calendar DAY_OF_MONTH
int DAY_OF_MONTH
To view the source code for java.util Calendar DAY_OF_MONTH.
Click Source Link
get
and set
indicating the day of the month. From source file:Main.java
/** * * This method is a utility method to create a new java.sql.Date in one line. * * @param year//ww w . j a v a 2 s. c o m * @param month * @param day * * @return a populated java.sql.Date with the year, month, and day specified, and no values for hour, minute, second, * millisecond * */ public static java.sql.Date newDate(Integer year, Integer month, Integer day) { // test for null arguments if (year == null) { throw new IllegalArgumentException("Argument 'year' passed in was null."); } if (month == null) { throw new IllegalArgumentException("Argument 'month' passed in was null."); } if (day == null) { throw new IllegalArgumentException("Argument 'day' passed in was null."); } Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.clear(Calendar.HOUR_OF_DAY); calendar.clear(Calendar.MINUTE); calendar.clear(Calendar.SECOND); calendar.clear(Calendar.MILLISECOND); return new java.sql.Date(calendar.getTimeInMillis()); }
From source file:rzd.vivc.documentexamination.form.service.DateFilterServiceWithCalendar.java
@Override public DateFilter createFirstAndLastDayOfMonth(Date dayOfMonth) { Calendar calendar = Calendar.getInstance(); calendar.setTime(dayOfMonth);//from www. j a v a2 s. com calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); // ? ?? Date start = calendar.getTime(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); Date finish = calendar.getTime(); return new DateFilter(start, finish); }
From source file:com.westlinkin.android_feedback_helper.utils.MailUntils.java
private static String getFeedbackNumber() { Calendar calendar = Calendar.getInstance(); return "" + calendar.get(Calendar.YEAR) + Utils.formatCalendarIntValue((calendar.get(Calendar.MONTH) + 1), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.DAY_OF_MONTH), 2) + "-" + Utils.formatCalendarIntValue(calendar.get(Calendar.HOUR_OF_DAY), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.MINUTE), 2) + Utils.formatCalendarIntValue(calendar.get(Calendar.SECOND), 2) + "-" + Utils.formatCalendarIntValue(calendar.get(Calendar.MILLISECOND), 3); }
From source file:love.sola.netsupport.api.API.java
public static Date getToday() { return DateUtils.truncate(new Date(), Calendar.DAY_OF_MONTH); }
From source file:Main.java
/** * Copy the year, month and day from a date to another * @param cOrigin Calendar origin where to get the data * @param cDestiny Calendar destiny where to set the data * @return Date with year month and day from dateOrigin and rest from dateDestiny *///from ww w. ja va2 s. com public static Calendar copyYearMonthDay(Calendar cOrigin, Calendar cDestiny) { //check null values if (cOrigin == null && cDestiny == null) { return Calendar.getInstance(); } else if (cOrigin == null) { return cDestiny; } else if (cDestiny == null) { return cOrigin; } //copy year, month and day cDestiny.set(Calendar.YEAR, cOrigin.get(Calendar.YEAR)); cDestiny.set(Calendar.MONTH, cOrigin.get(Calendar.MONTH)); cDestiny.set(Calendar.DAY_OF_MONTH, cOrigin.get(Calendar.DAY_OF_MONTH)); //return the time of destiny return cDestiny; }
From source file:attask.engine.ATTaskInterface.java
public static String calculateFormattedTimesheetStartDate() { SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//dd/MM/yyyy Date now = new Date(); int timesheetStart; Calendar cal = Calendar.getInstance(); int currDay = cal.get(Calendar.DAY_OF_MONTH); if (currDay < 16) { timesheetStart = 1;/*from w w w . j a v a2 s. co m*/ } else { timesheetStart = 16; } now.setDate(timesheetStart); String strDate = sdfDate.format(now); return strDate; }
From source file:cz.cvut.kbss.wpa.service.test.PlayerServiceTest.java
@BeforeClass public static void setUp() { b = Calendar.getInstance();//from ww w . j a v a 2 s. co m b.set(Calendar.YEAR, 1986); b.set(Calendar.MONTH, Calendar.APRIL); b.set(Calendar.DAY_OF_MONTH, 28); b.set(Calendar.HOUR, 0); b.set(Calendar.MINUTE, 0); b.set(Calendar.SECOND, 0); }
From source file:com.project.framework.util.DateUtils.java
/** * ????//from w ww . j ava2s . co m * * @param start * * @param end * * @return start<end0start=endstart>end */ public static int compare(Date start, Date end) { Calendar c1 = Calendar.getInstance(); c1.setTime(start); Calendar c2 = Calendar.getInstance(); c2.setTime(end); int year1 = c1.get(Calendar.YEAR); int year2 = c2.get(Calendar.YEAR); if (year1 != year2) { return year1 - year2; } int month1 = c1.get(Calendar.MONTH); int month2 = c2.get(Calendar.MONTH); if (month1 != month2) { return month1 - month2; } int day1 = c1.get(Calendar.DAY_OF_MONTH); int day2 = c2.get(Calendar.DAY_OF_MONTH); return day1 - day2; }
From source file:love.sola.netsupport.api.API.java
public static Date getDay(Date date) { return DateUtils.truncate(date, Calendar.DAY_OF_MONTH); }
From source file:Main.java
/** * @param date/* ww w .jav a 2 s.co m*/ * @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(); }