Start and end date of a current month

There you go: public Pair<Date, Date> getDateRange() { Date begining, end; { Calendar calendar = getCalendarForNow(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH)); setTimeToBeginningOfDay(calendar); begining = calendar.getTime(); } { Calendar calendar = getCalendarForNow(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); setTimeToEndofDay(calendar); end = calendar.getTime(); } return Pair.of(begining, end); } private static Calendar getCalendarForNow() { Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(new Date()); return calendar; } private static … Read more

How to add 30 minutes to a JavaScript Date object?

Using a Library If you are doing a lot of date work, you may want to look into JavaScript date libraries like Datejs or Moment.js. For example, with Moment.js, this is simply: var newDateObj = moment(oldDateObj).add(30, ‘m’).toDate(); Vanilla Javascript This is like chaos’s answer, but in one line: var newDateObj = new Date(oldDateObj.getTime() + diff*60000); … Read more