List of usage examples for java.util Calendar JANUARY
int JANUARY
To view the source code for java.util Calendar JANUARY.
Click Source Link
From source file:org.projectforge.common.DateHolder.java
/** * Sets the date to the beginning of the year (first day of year) and calls setBeginOfDay. * @see #setBeginOfDay()/*from www . jav a 2 s . c o m*/ */ public DateHolder setBeginOfYear() { calendar.set(Calendar.MONTH, Calendar.JANUARY); setBeginOfMonth(); return this; }
From source file:org.jfree.data.time.MillisecondTest.java
/** * Some checks for the getEnd() method.// ww w .j ava 2s .c om */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 555); Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); }
From source file:adalid.commons.util.TimeUtils.java
public static String jdbcTemporalString(Object object) { java.util.Date date = object instanceof java.util.Date ? (java.util.Date) object : null; if (date == null) { return null; }/*from w w w. j a v a 2s . c o m*/ Calendar c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); int dd = c.get(Calendar.YEAR); int MM = c.get(Calendar.MONTH); int yy = c.get(Calendar.DAY_OF_MONTH); int hh = c.get(Calendar.HOUR_OF_DAY); int mm = c.get(Calendar.MINUTE); int ss = c.get(Calendar.SECOND); int ms = c.get(Calendar.MILLISECOND); boolean dateless = dd == 1 && MM == Calendar.JANUARY && yy == 1970; boolean timeless = hh + mm + ss + ms == 0; return timeless ? jdbcDateString(date) : dateless ? jdbcTimeString(date) : jdbcTimestampString(date); }
From source file:org.techytax.util.DateHelper.java
public static boolean isTimeForUsingLatestYearPeriod() { Date currentDate = new Date(); Calendar cal = new GregorianCalendar(); cal.setTime(currentDate);//from w w w .j a v a 2 s .c o m cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DAY_OF_MONTH, 31); Date beginDate = cal.getTime(); cal.set(Calendar.MONTH, Calendar.APRIL); cal.set(Calendar.DAY_OF_MONTH, 1); Date endDate = cal.getTime(); return currentDate.after(beginDate) && currentDate.before(endDate); }
From source file:org.jfree.data.time.junit.HourTest.java
/** * Some checks for the getStart() method. *///from ww w . ja v a2s .c o m public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 0, 0); cal.set(Calendar.MILLISECOND, 0); Hour h = new Hour(3, 16, 1, 2006); assertEquals(cal.getTime(), h.getStart()); Locale.setDefault(saved); }
From source file:com.discovery.darchrow.date.DateUtil.java
/** * <code>week</code>.//from w w w .j av a2 s . c o m * * <pre> * 2015-7-29 14:08 * * DateUtil.getFirstWeekOfSpecifyDateYear(NOW, Calendar.FRIDAY) * return 2015-01-02 00:00:00.000 * * DateUtil.getFirstWeekOfSpecifyDateYear(NOW, Calendar.MONDAY) * return 2015-01-05 00:00:00.000 * </pre> * * @param date * * @param week * 1 ?2 3 4 5 6 7, ? {@link Calendar#SUNDAY}, {@link Calendar#MONDAY}, {@link Calendar#TUESDAY}, * {@link Calendar#WEDNESDAY}, {@link Calendar#THURSDAY}, {@link Calendar#FRIDAY}, {@link Calendar#SATURDAY} * @return the first week of specify date year * @see Calendar#SUNDAY * @see Calendar#MONDAY * @see Calendar#TUESDAY * @see Calendar#WEDNESDAY * @see Calendar#THURSDAY * @see Calendar#FRIDAY * @see Calendar#SATURDAY * @since 1.3.0 */ public static Date getFirstWeekOfSpecifyDateYear(Date date, int week) { Calendar calendar = toCalendar(date); calendar.clear(); calendar.set(Calendar.YEAR, getYear(date)); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DAY_OF_WEEK_IN_MONTH, 1); calendar.set(Calendar.DAY_OF_WEEK, week); //DAY_OF_WEEK_IN_MONTH ? DAY_OF_WEEK ??? // WEEK_OF_MONTH WEEK_OF_YEAR ??? ? getFirstDayOfWeek() getMinimalDaysInFirstWeek() //DAY_OF_MONTH 1 7 DAY_OF_WEEK_IN_MONTH 1 //8 14 DAY_OF_WEEK_IN_MONTH 2? //DAY_OF_WEEK_IN_MONTH 0 DAY_OF_WEEK_IN_MONTH 1 ? //?? DAY_OF_WEEK = SUNDAY, DAY_OF_WEEK_IN_MONTH = -1 //????? // 31 DAY_OF_WEEK_IN_MONTH -1 DAY_OF_WEEK_IN_MONTH 5 DAY_OF_WEEK_IN_MONTH 4 ?? return CalendarUtil.toDate(calendar); }
From source file:org.jfree.data.time.DayTest.java
/** * Some checks for the getEnd() method./*from w w w . j a v a 2 s.co m*/ */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(1900, Calendar.JANUARY, 1, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Day d = new Day(1, 1, 1900); assertEquals(cal.getTime(), d.getEnd()); Locale.setDefault(saved); }
From source file:org.jfree.data.time.MonthTest.java
/** * Some checks for the getEnd() method.// www.j a va 2 s . co m */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 31, 23, 59, 59); cal.set(Calendar.MILLISECOND, 999); Month m = new Month(1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); }
From source file:com.feilong.core.date.DateUtil.java
/** * <code>date</code><span style="color:red"></span>,<code>00:00:00.000</code> . * /*w ww .j av a2 s. co m*/ * <pre class="code"> * DateUtil.getFirstDateOfThisYear(2012-10-11 17:10:30.701)=2012-01-01 00:00:00 * </pre> * * @param date * ? * @return <code>date</code> null, {@link NullPointerException} * @see #toCalendar(Date) * @see Calendar#set(int, int) * @see CalendarUtil#resetDayBegin(Calendar) * @see Calendar#getTime() */ public static Date getFirstDateOfThisYear(Date date) { Calendar calendar = toCalendar(date); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DAY_OF_MONTH, 1); return CalendarUtil.toDate(CalendarUtil.resetDayBegin(calendar)); }
From source file:org.mifos.customers.client.persistence.ClientPersistenceIntegrationTest.java
public void testShouldThrowExceptionWhenTryingToUpdateClientGovtIdToGovtIdOfAnActiveClient() throws Exception { setUpClients();/* www . j a v a 2 s . c o m*/ localTestClient = createActiveClientWithGovtId(); clientWithSameGovtId = TestObjectFactory.createClient(this.getClass().getSimpleName() + " Duplicate Client", CustomerStatus.CLIENT_ACTIVE, group); try { clientWithSameGovtId.updatePersonalInfo(this.getClass().getSimpleName() + " Duplicate Client", GOVT_ID, DateUtils.getDate(1980, Calendar.JANUARY, 1)); StaticHibernateUtil.commitTransaction(); Assert.fail("Should throw error when updating to a government id of active client"); } catch (CustomerException e) { Assert.assertEquals(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION, e.getKey()); } }