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:com.stratelia.webactiv.util.DateUtilTest.java
@Test public void testGetEndDateOfWeekFRBetween2Years() { Date dateTest = DateUtil.getEndDateOfWeek(java.sql.Date.valueOf("2013-12-31"), "fr"); Calendar cal = DateUtil.convert(dateTest); assertThat(cal.get(Calendar.YEAR), is(2014)); assertThat(cal.get(Calendar.MONTH), is(Calendar.JANUARY)); assertThat(cal.get(Calendar.DAY_OF_MONTH), is(5)); assertThat(cal.get(Calendar.HOUR_OF_DAY), is(23)); assertThat(cal.get(Calendar.MINUTE), is(59)); assertThat(cal.get(Calendar.SECOND), is(59)); assertThat(cal.get(Calendar.MILLISECOND), is(999)); }
From source file:com.survivingwithandroid.weather.lib.provider.wunderground.WeatherUndergroundProvider.java
@Override public HistoricalWeather getHistoricalWeather(String data) throws WeatherLibException { HistoricalWeather histWeather = new HistoricalWeather(); try {//w ww. j av a2 s . c o m JSONObject jObj = new JSONObject(data); JSONObject histObj = jObj.getJSONObject("history"); // We move to the list tag JSONArray wList = histObj.getJSONArray("observations"); for (int i = 0; i < wList.length(); i++) { HistoricalHourWeather hhWeather = new HistoricalHourWeather(); JSONObject jHour = wList.getJSONObject(i); JSONObject utcObj = jHour.getJSONObject("utcdate"); int y = utcObj.getInt("year"); int m = utcObj.getInt("mon"); int mday = utcObj.getInt("mday"); int h = utcObj.getInt("hour"); int min = utcObj.getInt("min"); Calendar cal = GregorianCalendar.getInstance(); cal.set(y, Calendar.JANUARY, mday, h, min); cal.add(Calendar.MONTH, m - 1); hhWeather.timestamp = cal.getTimeInMillis(); String tag = null; if (WeatherUtility.isMetric(config.unitSystem)) tag = "m"; else tag = "i"; hhWeather.weather.temperature.setTemp((float) jHour.getDouble("temp" + tag)); hhWeather.weather.currentCondition.setDewPoint((float) jHour.getDouble("dewpt" + tag)); hhWeather.weather.currentCondition.setHumidity((float) jHour.getInt("hum")); hhWeather.weather.wind.setSpeed((float) jHour.getDouble("wspd" + tag)); hhWeather.weather.wind.setGust((float) jHour.getDouble("wgust" + tag)); hhWeather.weather.wind.setDeg((float) jHour.getDouble("wdird")); hhWeather.weather.wind.setChill((float) jHour.getDouble("windchill" + tag)); hhWeather.weather.currentCondition.setVisibility((float) jHour.getDouble("vis" + tag)); hhWeather.weather.currentCondition.setPressure((float) jHour.getDouble("pressure" + tag)); hhWeather.weather.currentCondition.setHeatIndex(jHour.getString("heatindex" + tag)); hhWeather.weather.rain[0].setAmmount((float) jHour.getDouble("precip" + tag)); hhWeather.weather.currentCondition.setDescr(jHour.getString("conds")); hhWeather.weather.currentCondition.setIcon(jHour.getString("icon")); if (codeProvider != null) hhWeather.weather.currentCondition.setWeatherCode( codeProvider.getWeatherCode(hhWeather.weather.currentCondition.getIcon())); // fog, hail, tornado and so on still not supported histWeather.addHistoricalHourWeather(hhWeather); } } catch (JSONException json) { throw new WeatherLibException(json); } histWeather.setUnit(units); return histWeather; }
From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java
public static int getDaysInMonth(int month, int year) { switch (month) { case Calendar.JANUARY: case Calendar.MARCH: case Calendar.MAY: case Calendar.JULY: case Calendar.AUGUST: case Calendar.OCTOBER: case Calendar.DECEMBER: return 31; case Calendar.APRIL: case Calendar.JUNE: case Calendar.SEPTEMBER: case Calendar.NOVEMBER: return 30; case Calendar.FEBRUARY: // This is not correct. See isLeapYear(int) above //return (year % 4 == 0) ? 29 : 28; return isLeapYear(year) ? 29 : 28; default:/*ww w .j a va 2s . co m*/ throw new IllegalArgumentException("Invalid Month"); } }
From source file:ch.cyberduck.core.ftp.parser.UnixFTPEntryParserTest.java
@Test public void testWindowsNTSystem() { FTPFileEntryParser parser = new FTPParserSelector().getParser("Windows_NT version 5.0"); FTPFile parsed;/*from ww w . j ava 2s . c om*/ // #5505 parsed = parser.parseFTPEntry( "drwxrwxrwx 1 owner group 0 Dec 5 0:45 adele.handmadebyflloyd.com"); assertNotNull(parsed); assertEquals("adele.handmadebyflloyd.com", parsed.getName()); assertEquals("owner", parsed.getUser()); assertEquals("group", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.DECEMBER, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(5, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); // #5505 parsed = parser.parseFTPEntry("drwxrwxrwx 1 owner group 0 Jan 22 2009 contact"); assertNotNull(parsed); assertEquals("contact", parsed.getName()); assertEquals("owner", parsed.getUser()); assertEquals("group", parsed.getGroup()); assertNotNull(parsed.getTimestamp()); assertEquals(Calendar.JANUARY, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(22, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(2009, parsed.getTimestamp().get(Calendar.YEAR)); }
From source file:agency.AgencyManagerImplTest.java
private static Agent newAgent01() { Calendar cal = new GregorianCalendar(1980, Calendar.JANUARY, 1); return newAgent("James Bond", cal.getTime(), 5, "Best agent ever"); }
From source file:adalid.commons.util.TimeUtils.java
public static Calendar newTimeCalendar(java.util.Date date) { if (date == null) { return null; }//from w w w.j ava2 s . co m Calendar c = Calendar.getInstance(); c.setTimeInMillis(date.getTime()); c.set(Calendar.YEAR, 1970); c.set(Calendar.MONTH, Calendar.JANUARY); c.set(Calendar.DAY_OF_MONTH, 1); return c; }
From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java
/** * @see PortletsController#isEndDateBeforeStartDate(Date, Date) * @verifies return false if end date is not after start date */// www .j a va 2s. c o m @Test public void isEndDateBeforeStartDate_shouldReturnFalseIfEndDateIsNotAfterStartDate() throws Exception { Method isEndDateBeforeStartDateMethod = portletsController.getClass().getDeclaredMethod( "isEndDateBeforeStartDate", new Class[] { java.util.Date.class, java.util.Date.class }); isEndDateBeforeStartDateMethod.setAccessible(true); Date startDate = new GregorianCalendar(2001, Calendar.JANUARY, 01).getTime(); Date endDate = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime(); Boolean isEndDateBeforeStartDate = (Boolean) isEndDateBeforeStartDateMethod.invoke(portletsController, new Object[] { startDate, endDate }); assertThat(isEndDateBeforeStartDate, is(false)); }
From source file:com.lloydtorres.stately.helpers.RaraHelper.java
/** * Determines if the current day in the EST/EDT timezone is a special day. * @return The special day mode/*from w ww. ja v a 2s . c om*/ */ public static int getSpecialDayStatus() { Calendar cal = new GregorianCalendar(); cal.setTimeZone(SparkleHelper.TIMEZONE_TORONTO); int month = cal.get(Calendar.MONTH); int day = cal.get(Calendar.DAY_OF_MONTH); if (month == Calendar.JANUARY && day == 30) { return DAY_STATELY_BIRTHDAY; } else if (month == Calendar.JULY && day == 1) { return DAY_CANADA_DAY; } else if (month == Calendar.OCTOBER && day == 31) { return DAY_HALLOWEEN; } else if (month == Calendar.NOVEMBER && day == 13) { return DAY_NS_BIRTHDAY; } else { return DAY_NORMAL; } }
From source file:br.msf.commons.util.AbstractDateUtils.java
protected static Collection<Calendar> getBrasilianHolidays(final int year) { Collection<Calendar> holidays = new ArrayList<>(); // feriados fixos holidays.add(new GregorianCalendar(year, Calendar.JANUARY, 1)); // Confraternizacao Universal holidays.add(new GregorianCalendar(year, Calendar.APRIL, 21)); // Tiradentes holidays.add(new GregorianCalendar(year, Calendar.MAY, 1)); // Dia do Trabalho holidays.add(new GregorianCalendar(year, Calendar.OCTOBER, 12)); // Nossa Senhora Aparecida holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 2)); // Finados holidays.add(new GregorianCalendar(year, Calendar.NOVEMBER, 15)); // Proclamacao da Republica holidays.add(new GregorianCalendar(year, Calendar.DECEMBER, 25)); // Natal // feriados calculados Calendar pascoa = getSundayOfEaster(year); Calendar carnaval = (Calendar) pascoa.clone(); carnaval.add(Calendar.DAY_OF_MONTH, -47); Calendar corpusChristi = (Calendar) pascoa.clone(); corpusChristi.add(Calendar.DAY_OF_MONTH, 60); holidays.add(carnaval); // Carnaval holidays.add(pascoa); // Pascoa holidays.add(corpusChristi); // Corpus Christi return holidays; }
From source file:myorg.relex.One2OneTest.java
/** * This test provides a demonstration of creating a one-to-one * bi-directional relationship using entities that will share * a generated primary key value and be joined by their common * primary key value./*from w ww .j a v a2s .c o m*/ */ @Test public void testOne2OneBiPKJ() { log.info("*** testOne2OneBiPKJ() ***"); Applicant applicant = new Applicant(); applicant.setName("Jason Garret"); Application application = new Application(applicant); application.setDesiredStartDate(new GregorianCalendar(2008, Calendar.JANUARY, 1).getTime()); em.persist(applicant); //provider will generate a PK em.persist(application); //provider will propogate parent.PK to dependent.FK/PK //clear the persistence context and get new instances from the owning side em.flush(); em.clear(); log.info("finding dependent..."); Application application2 = em.find(Application.class, application.getId()); log.info("found dependent..."); assertTrue("unexpected startDate", application.getDesiredStartDate().equals(application2.getDesiredStartDate())); log.info("calling parent..."); assertEquals("unexpected name", application.getApplicant().getName(), application2.getApplicant().getName()); //clear the persistence context and get new instances from the inverse side em.flush(); em.clear(); log.info("finding parent..."); Applicant applicant2 = em.find(Applicant.class, applicant.getId()); log.info("found parent..."); assertEquals("unexpected name", applicant.getName(), applicant2.getName()); log.info("calling dependent..."); assertTrue("unexpected startDate", applicant.getApplication().getDesiredStartDate() .equals(applicant2.getApplication().getDesiredStartDate())); //remove the objects and flush commands to the database em.remove(applicant2.getApplication()); em.remove(applicant2); em.flush(); assertNull("applicant not deleted", em.find(Applicant.class, applicant2.getId())); assertNull("application not deleted", em.find(Application.class, applicant2.getApplication().getId())); }