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.projity.util.DateTime.java
public static Calendar getMaxCalendar() { if (maxCalendarInstance == null) maxCalendarInstance = calendarInstance(2050, Calendar.JANUARY, 0); return maxCalendarInstance; }
From source file:mailjimp.service.TestMailJimpJsonService.java
@Test public void testListMembersAllPopulated() { try {/*from ww w . j a v a2 s . com*/ Calendar i = Calendar.getInstance(); i.set(Calendar.YEAR, 2011); i.set(Calendar.MONTH, Calendar.JANUARY); i.set(Calendar.DATE, 1); log.debug("Test list members - all populated"); List<MemberResponseInfo> content = mSvc.listMembers(listId, MemberStatus.subscribed, i.getTime(), 0, 100); log.debug("Lists Content: {}", content); } catch (MailJimpException mje) { processError(mje); } }
From source file:com.liferay.google.GoogleOAuth.java
protected User addUser(HttpSession session, long companyId, Userinfoplus userinfo) throws Exception { long creatorUserId = 0; boolean autoPassword = true; String password1 = StringPool.BLANK; String password2 = StringPool.BLANK; boolean autoScreenName = true; String screenName = StringPool.BLANK; String emailAddress = userinfo.getEmail(); String openId = StringPool.BLANK; Locale locale = LocaleUtil.getDefault(); String firstName = userinfo.getGivenName(); String middleName = StringPool.BLANK; String lastName = userinfo.getFamilyName(); int prefixId = 0; int suffixId = 0; boolean male = Validator.equals(userinfo.getGender(), "male"); int birthdayMonth = Calendar.JANUARY; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = StringPool.BLANK; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = new ServiceContext(); User user = UserLocalServiceUtil.addUser(creatorUserId, companyId, autoPassword, password1, password2, autoScreenName, screenName, emailAddress, 0, openId, locale, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP()); user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false); user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), true); session.setAttribute("GOOGLE_USER_EMAIL_ADDRESS", emailAddress); return user;// w ww. j a v a 2 s .c om }
From source file:com.microsoft.tfs.core.clients.versioncontrol.workspacecache.WorkspaceInfo.java
public WorkspaceInfo(final InternalServerInfo serverInfo, final Workspace workspace) { Check.notNull(serverInfo, "serverInfo"); //$NON-NLS-1$ Check.notNull(workspace, "workspace"); //$NON-NLS-1$ this.serverInfo = serverInfo; this.comment = workspace.getComment(); this.computer = workspace.getComputer(); this.isLocalWorkspace = (workspace.getLocation() == WorkspaceLocation.LOCAL); this.name = workspace.getName(); this.ownerName = workspace.getOwnerName(); this.ownerDisplayName = workspace.getOwnerDisplayName(); this.securityToken = workspace.getSecurityToken(); this.mappedPaths = WorkingFolder.extractMappedPaths(workspace.getFolders()); this.options = workspace.getOptions(); this.ownerAliases = workspace.getOwnerAliases() != null ? workspace.getOwnerAliases().clone() : new String[0]; this.state = LocalWorkspaceState.NEW; lastSavedCheckinTimeStamp = Calendar.getInstance(TimeZone.getTimeZone("UTC")); //$NON-NLS-1$ lastSavedCheckinTimeStamp.set(1, Calendar.JANUARY, 1, 0, 0, 0); lastSavedCheckinTimeStamp.set(Calendar.MILLISECOND, 0); Check.isTrue(this.name.equals(this.ownerName) == false, MessageFormat .format("Something went wrong since name and owner are the same: {0}", this.toString())); //$NON-NLS-1$ }
From source file:org.pentaho.metaverse.api.MetaverseLogicalIdGeneratorTest.java
@Test public void testGenerateLogicalId_duplicateKey() throws Exception { when(node.getProperty("name")).thenReturn("john doe"); when(node.getProperty("age")).thenReturn(30); when(node.getProperty("address")).thenReturn("1234 Pentaho Way Orlando, FL 12345"); Calendar cal = GregorianCalendar.getInstance(); cal.set(1976, Calendar.JANUARY, 1, 0, 0, 0); when(node.getProperty("birthday")).thenReturn(cal.getTime()); when(node.getPropertyKeys()).thenReturn(new HashSet<String>() { {//from w ww . ja v a 2 s .co m add("address"); add("age"); add("birthday"); add("name"); } }); String logicalId = idGenerator.generateId(node); // it should come out in alphabetical order by key assertEquals("{\"address\":\"1234 Pentaho Way " + "Orlando, FL 12345\",\"age\":\"30\",\"birthday\":\"1976-01-01 00:00:00\",\"name\":\"john doe\"}", logicalId); // make sure a call was made to add the logical id as a property verify(node).setProperty(DictionaryConst.PROPERTY_LOGICAL_ID, logicalId); }
From source file:org.openmrs.module.radiology.web.controller.PortletsControllerTest.java
/** * @see PortletsController#getRadiologyOrdersByPatientQueryAndDateRange(String, Date, Date) * @verifies not populate model and view with table of orders if start date is after end date *//* w w w .ja va 2 s. c o m*/ @Test public void ordersTable_shouldNotPopulateModelAndViewWithTableOfOrdersIfStartDateIsAfterEndDate() throws Exception { //given String patientQuery = ""; Date startDate = new GregorianCalendar(2010, Calendar.OCTOBER, 10).getTime(); Date endDate = new GregorianCalendar(2001, Calendar.JANUARY, 01).getTime(); ModelAndView mav = portletsController.getRadiologyOrdersByPatientQueryAndDateRange(patientQuery, startDate, endDate); assertThat(mav, is(notNullValue())); assertThat(mav.getModelMap(), hasKey("orderList")); List<RadiologyOrder> orderList = (List<RadiologyOrder>) mav.getModelMap().get("orderList"); assertThat(orderList, is(notNullValue())); assertThat(orderList, is(empty())); assertThat(mav.getModelMap(), hasKey("exceptionText")); String exception = (String) mav.getModelMap().get("exceptionText"); assertThat(exception, is(notNullValue())); assertThat(exception, is("radiology.crossDate")); }
From source file:com.sunrun.crportal.util.CRPortalUtil.java
public static User addCustomerUserToLRDatabase(String customerId, Company co, String emailAddress, String password) throws PortalException, SystemException, NumberFormatException, GatewayException { // TODO-CP2.0 Cleanup this code. ResidentialCustomer010000 residentialCustomer = null; AccountModel accountModel = new SunRunAccountGateway(); residentialCustomer = (ResidentialCustomer010000) accountModel.getCustomer(Integer.parseInt(customerId)); long creatorUserId = 0; boolean autoPassword = false; // we have to set the password to something. replace this in the // future with something smarter boolean autoScreenName = false; Locale locale = Locale.US; password = "replaceme"; String userScreenName = customerId; String firstName = residentialCustomer.getFirstName(); String middleName = null;/*from w ww . j a v a 2 s .com*/ String lastName = residentialCustomer.getLastName(); long facebookId = 99; long[] ids; ids = new long[0]; long[] communityIds = new long[2]; communityIds[0] = co.getGroup().getGroupId(); //Add the SUNRUNHOME.COM community Group group = GroupServiceUtil.getGroup(co.getCompanyId(), "Guest"); communityIds[1] = group.getGroupId(); //communityIds[1] = 10527; int prefixId = 0; int suffixId = 0; boolean male = true; int birthdayMonth = Calendar.JANUARY; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = null; boolean sendEmail = false; // setting password to null returns errors (actually null) User user = UserLocalServiceUtil.addUser(creatorUserId, co.getCompanyId(), autoPassword, password, password, autoScreenName, userScreenName, emailAddress, facebookId, customerId, locale, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, communityIds, ids, ids, ids, sendEmail, null); LOG.info("Added the customer user with " + emailAddress + " to the Liferay database."); return user; }
From source file:org.openvpms.web.echo.date.RelativeDateParser.java
/** * Parses a date relative to the specified date. * * @param source the relative date string * @param date the date/*from w ww . j a v a 2 s. co m*/ * @return the relative date, or <code>null</code> if the source is invalid */ public Date parse(String source, Date date) { if (StringUtils.isEmpty(source)) { return null; } Matcher matcher = pattern.matcher(source.toLowerCase()); Calendar calendar; calendar = new GregorianCalendar(); calendar.setTime(date); int start = 0; boolean neg = false; boolean first = true; while (start < source.length() && matcher.find(start)) { if (start != matcher.start()) { return null; } String valueGroup = matcher.group(1); int value = Integer.parseInt(valueGroup); if (first) { if (value < 0) { neg = true; } first = false; } else if (value >= 0 && valueGroup.charAt(0) != '+' && neg) { // if there is a leading sign, and the current value has no explicit +, it propagates to all // other patterns where no sign is specified value = -value; } String field = matcher.group(2); String se = matcher.group(3); // get any s=start or e=end if (field.equals("d")) { calendar.add(Calendar.DAY_OF_MONTH, value); // se ignored if day } else if (field.equals("m")) { calendar.add(Calendar.MONTH, value); if (se.equals("s")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month } else if (se.equals("e")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month calendar.add(Calendar.MONTH, 1); // go to next month calendar.add(Calendar.DAY_OF_MONTH, -1); // back one to to get end of month } } else if (field.equals("w")) { calendar.add(Calendar.WEEK_OF_YEAR, value); if (se.equals("s")) { calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); //set Monday } else if (se.equals("e")) { calendar.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); //set Friday } } else if (field.equals("q")) { // quarter calendar.add(Calendar.MONTH, 3 * value); // move by 3 month blocks if (se.equals("s")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month int k = calendar.get(Calendar.MONTH); // get month (0 = Jan) k = (k / 3) * 3; // get month number at start of quarter (0,3,6,9) calendar.set(Calendar.MONTH, k); // set that month } else if (se.equals("e")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month int k = calendar.get(Calendar.MONTH); // get month (0 = Jan) k = (k / 3) * 3; // get month number at start of quarter (0,3,6,9) calendar.set(Calendar.MONTH, k); // set that month calendar.add(Calendar.MONTH, 3); // go to next quarter calendar.add(Calendar.DAY_OF_MONTH, -1); // back one day to to get end of quarter } } else { calendar.add(Calendar.YEAR, value); if (se.equals("s")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month calendar.set(Calendar.MONTH, Calendar.JANUARY); // set January } else if (se.equals("e")) { calendar.set(Calendar.DAY_OF_MONTH, 1); // set 1st of month calendar.set(Calendar.MONTH, Calendar.JANUARY); // set January calendar.add(Calendar.YEAR, 1); // go to next year calendar.add(Calendar.DAY_OF_MONTH, -1); // back one to to get 31 Dec } } start = matcher.end(); } return (start == source.length()) ? calendar.getTime() : null; }
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.AmendmentXmlSerializerTest.java
public void testReadElement() { expect(element.attributeValue("name")).andReturn("Amendment 1"); expect(element.attributeValue("date")).andReturn("2008-01-02"); expect(element.attributeValue("mandatory")).andReturn("true"); expect(element.attributeValue("previous-amendment-key")).andReturn("2008-01-01~Amendment 0"); expect(element.elements()).andReturn(Collections.singletonList(eDelta)); expect(deltaSerializerFactory.createXmlSerializer(eDelta)).andReturn(deltaSerializer); expect(deltaSerializer.readElement(eDelta)).andReturn(delta); replayMocks();/*from w w w . j av a 2 s . c o m*/ Amendment actual = serializer.readElement(element); verifyMocks(); assertEquals("Wrong name", "Amendment 1", actual.getName()); assertSameDay("Wrong date", createDate(2008, Calendar.JANUARY, 2), actual.getDate()); assertTrue("Should be mandatory", actual.isMandatory()); assertSame("Wrong previous amendment", amendment0, actual.getPreviousAmendment()); }
From source file:org.openlmis.core.repository.mapper.UserMapperIT.java
@Test public void shouldInsertUserWithSuppliedModifiedDate() throws Exception { User someUser = make(a(defaultUser, with(facilityId, facility.getId()), with(active, true))); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, Calendar.JANUARY); someUser.setModifiedDate(calendar.getTime()); userMapper.insert(someUser);// ww w . j a va 2 s.c om User fetchedUser = userMapper.getByUserName(someUser.getUserName()); assertThat(fetchedUser, is(notNullValue())); assertThat(fetchedUser.getId(), is(someUser.getId())); assertThat(fetchedUser.getModifiedDate(), is(calendar.getTime())); }