List of usage examples for java.util Date getYear
@Deprecated public int getYear()
From source file:org.kuali.coeus.common.impl.editable.PersonEditableServiceImpl.java
public void populateContactFieldsFromPersonId(PersonEditable protocolPerson) { DateFormat dateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT_PATTERN); KcPerson person = this.kcPersonService.getKcPersonByPersonId(protocolPerson.getPersonId()); protocolPerson.setSocialSecurityNumber(person.getSocialSecurityNumber()); protocolPerson.setLastName(person.getLastName()); protocolPerson.setFirstName(person.getFirstName()); protocolPerson.setMiddleName(person.getMiddleName()); protocolPerson.setFullName(person.getFullName()); protocolPerson.setPriorName(person.getPriorName()); protocolPerson.setUserName(person.getUserName()); protocolPerson.setEmailAddress(person.getEmailAddress()); try {/*from w w w . j a v a 2 s.c om*/ java.util.Date dobUtil = dateFormat.parse(person.getDateOfBirth()); protocolPerson .setDateOfBirth(new java.sql.Date(dobUtil.getYear(), dobUtil.getMonth(), dobUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setDateOfBirth(null); } protocolPerson.setAge(person.getAge()); protocolPerson.setAgeByFiscalYear(person.getAgeByFiscalYear()); protocolPerson.setGender(person.getGender()); protocolPerson.setRace(person.getRace()); protocolPerson.setEducationLevel(person.getEducationLevel()); protocolPerson.setDegree(person.getDegree()); protocolPerson.setMajor(person.getMajor()); protocolPerson.setHandicappedFlag(person.getHandicappedFlag()); protocolPerson.setHandicapType(person.getHandicapType()); protocolPerson.setVeteranFlag(person.getVeteranFlag()); protocolPerson.setVeteranType(person.getVeteranType()); protocolPerson.setVisaCode(person.getVisaCode()); protocolPerson.setVisaType(person.getVisaType()); try { java.util.Date visaUtil = dateFormat.parse(person.getVisaRenewalDate()); protocolPerson.setVisaRenewalDate( new java.sql.Date(visaUtil.getYear(), visaUtil.getMonth(), visaUtil.getDate())); } catch (Exception e) { //invalid date protocolPerson.setVisaRenewalDate(null); } protocolPerson.setHasVisa(person.getHasVisa()); protocolPerson.setOfficeLocation(person.getOfficeLocation()); protocolPerson.setOfficePhone(person.getOfficePhone()); protocolPerson.setSecondaryOfficeLocation(person.getSecondaryOfficeLocation()); protocolPerson.setSecondaryOfficePhone(person.getSecondaryOfficePhone()); protocolPerson.setSchool(person.getSchool()); protocolPerson.setYearGraduated(person.getYearGraduated()); protocolPerson.setDirectoryDepartment(person.getDirectoryDepartment()); protocolPerson.setSaluation(person.getSaluation()); protocolPerson.setCountryOfCitizenship(person.getCountryOfCitizenship()); protocolPerson.setPrimaryTitle(person.getPrimaryTitle()); protocolPerson.setDirectoryTitle(person.getDirectoryTitle()); protocolPerson.setHomeUnit(person.getOrganizationIdentifier()); protocolPerson.setFacultyFlag(person.getFacultyFlag()); protocolPerson.setGraduateStudentStaffFlag(person.getGraduateStudentStaffFlag()); protocolPerson.setResearchStaffFlag(person.getResearchStaffFlag()); protocolPerson.setServiceStaffFlag(person.getServiceStaffFlag()); protocolPerson.setSupportStaffFlag(person.getSupportStaffFlag()); protocolPerson.setOtherAcademicGroupFlag(person.getOtherAcademicGroupFlag()); protocolPerson.setMedicalStaffFlag(person.getMedicalStaffFlag()); protocolPerson.setVacationAccrualFlag(person.getVacationAccrualFlag()); protocolPerson.setOnSabbaticalFlag(person.getOnSabbaticalFlag()); protocolPerson.setIdProvided(person.getIdProvided()); protocolPerson.setIdVerified(person.getIdVerified()); protocolPerson.setAddressLine1(person.getAddressLine1()); protocolPerson.setAddressLine2(person.getAddressLine2()); protocolPerson.setAddressLine3(person.getAddressLine3()); protocolPerson.setCity(person.getCity()); protocolPerson.setCounty(person.getCounty()); protocolPerson.setState(person.getState()); protocolPerson.setPostalCode(person.getPostalCode()); protocolPerson.setCountryCode(person.getCountryCode()); protocolPerson.setFaxNumber(person.getFaxNumber()); protocolPerson.setPagerNumber(person.getPagerNumber()); protocolPerson.setMobilePhoneNumber(person.getMobilePhoneNumber()); protocolPerson.setEraCommonsUserName(person.getEraCommonsUserName()); protocolPerson.setCitizenshipTypeCode(person.getCitizenshipTypeCode()); }
From source file:de.grobox.liberario.TripDetailActivity.java
@SuppressWarnings("deprecation") private void addHeader(Trip trip) { Date d = trip.getFirstDepartureTime(); ((TextView) findViewById(R.id.tripDetailsDurationView)) .setText(DateUtils.getDuration(trip.getFirstDepartureTime(), trip.getLastArrivalTime())); ((TextView) findViewById(R.id.tripDetailsDateView)) .setText(DateUtils.formatDate(this, d.getYear() + 1900, d.getMonth(), d.getDate())); }
From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java
/** * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment} * * @param dateBoxInitDate//from w w w. j ava2 s. c o m * @param hourCost */ private void bindDateboxEndDate(final Datebox dateBoxEndDate, final ResourcesCostCategoryAssignment assignment) { Util.bind(dateBoxEndDate, new Util.Getter<Date>() { @Override public Date get() { LocalDate dateTime = assignment.getEndDate(); if (dateTime != null) { return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth()); } return null; } }, new Util.Setter<Date>() { @Override public void set(Date value) { if (value != null) { assignment.setEndDate( new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate())); } else { assignment.setEndDate(null); } } }); }
From source file:org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController.java
/** * Binds Datebox "init date" to the corresponding attribute of a {@link ResourcesCostCategoryAssignment} * * @param dateBoxInitDate/*ww w . j a v a 2s . c om*/ * @param hourCost */ private void bindDateboxInitDate(final Datebox dateBoxInitDate, final ResourcesCostCategoryAssignment assignment) { Util.bind(dateBoxInitDate, new Util.Getter<Date>() { @Override public Date get() { LocalDate dateTime = assignment.getInitDate(); if (dateTime != null) { return new Date(dateTime.getYear() - 1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth()); } return null; } }, new Util.Setter<Date>() { @Override public void set(Date value) { if (value != null) { assignment.setInitDate( new LocalDate(value.getYear() + 1900, value.getMonth() + 1, value.getDate())); } else { assignment.setInitDate(null); } } }); }
From source file:com.javielinux.utils.Utils.java
public static String timeFromTweet(Context cnt, Date timeTweet) { if (Integer.parseInt(Utils.getPreference(cnt).getString("prf_date_format", "1")) == 1) { return diffDate(new Date(), timeTweet); } else {/* ww w.j av a2 s. com*/ Date now = new Date(); if (now.getDay() == timeTweet.getDay() && now.getMonth() == timeTweet.getMonth() && now.getYear() == timeTweet.getYear()) { return DateFormat.getTimeInstance().format(timeTweet); } else { return DateFormat.getDateInstance().format(timeTweet); } } }
From source file:com.androzic.plugin.tracker.SMSReceiver.java
private boolean parseJointechJT600(String text, Tracker tracker) { // Jointech JT600 // jeson,09-28 12:11:02,Speed:32km/h,Battery:80%,GPS:13,STANDARD, // http://maps.google.com/?q=22.549737N,114.076685E // 3110701703,09-28 12:11:02,Speed:0km/h,Charging,Base Station,STANDARD,Cell ID:4195,LAC:230 // 3110701703,04-24 22:44:33,Speed:0km/h,Battery:90%,GPS:8,STANDARD, // http://maps.google.com/?q=60.010245N,30.288323E // ALM,SOS,3110701703,09-28 12:11:02,Speed:32km/h,Battery:80%,GPS:13,STANDARD,http://maps.google.com/?q=22.549737N,114.076685E // http://fiddle.re/yv1h6 Pattern pattern = Pattern.compile( "(?:ALM,)?(?:(.*),)?([^,]+),([\\d\\-:\\s]+),(?:Speed:(\\d+)km/h,)?(?:Battery:(\\d+)%|Charging),[^,]+,[^,]+,(?:\\r?\\n)?http://maps\\.google\\.com/\\?q=([^,]+),(.+)"); Matcher m = pattern.matcher(text); if (!m.matches()) return false; String latitude = m.group(6); String longitude = m.group(7); double coords[] = CoordinateParser.parse(latitude + " " + longitude); if (Double.isNaN(coords[0]) || Double.isNaN(coords[1])) return false; tracker.latitude = coords[0];//ww w . j a va2 s .co m tracker.longitude = coords[1]; try { String speed = m.group(4); if (speed != null) tracker.speed = Double.parseDouble(speed) / 3.6; } catch (NumberFormatException ignore) { } String time = m.group(3); try { Date date = JointechDateFormatter.parse(time); Date now = new Date(); date.setYear(now.getYear()); tracker.time = date.getTime(); } catch (Exception e) { Log.e(TAG, "Date error", e); } String battery = m.group(5); try { tracker.battery = Integer.parseInt(battery); } catch (NumberFormatException ignore) { } tracker.imei = m.group(2); String message = m.group(1); if (!"".equals(message)) tracker.message = message; return true; }
From source file:org.kuali.kpme.core.workarea.validation.WorkAreaMaintenanceDocumentRule.java
protected boolean validateRoleMembers(WorkAreaBo wa, List<? extends PrincipalRoleMemberBo> principalRoleMembers, List<? extends PositionRoleMemberBo> positionRoleMembers, LocalDate effectiveDate, String principalPrefix, String positionPrefix) { boolean valid = true; boolean activeRoleMember = false; Date efftDt = wa.getEffectiveDate(); Timestamp efftTs = new Timestamp(efftDt.getYear(), efftDt.getMonth(), efftDt.getDate(), 0, 0, 0, 0); for (ListIterator<? extends KPMERoleMemberBo> iterator = principalRoleMembers.listIterator(); iterator .hasNext();) {/*from w ww.j a va 2s . co m*/ int index = iterator.nextIndex(); KPMERoleMemberBo roleMember = iterator.next(); activeRoleMember |= roleMember.isActive(efftTs); } for (ListIterator<? extends KPMERoleMemberBo> iterator = positionRoleMembers.listIterator(); iterator .hasNext();) { int index = iterator.nextIndex(); KPMERoleMemberBo roleMember = iterator.next(); activeRoleMember |= roleMember.isActive(efftTs); valid &= validateRoleMember(roleMember, effectiveDate, positionPrefix, index); } if (!activeRoleMember) { this.putGlobalError("role.required"); valid = false; } return valid; }
From source file:com.datatorrent.contrib.enrich.FileEnrichmentTest.java
@Test public void testEnrichmentOperatorDelimitedFSLoader() throws IOException, InterruptedException { URL origUrl = this.getClass().getResource("/productmapping-delim.txt"); URL fileUrl = new URL(this.getClass().getResource("/").toString() + "productmapping-delim1.txt"); FileUtils.deleteQuietly(new File(fileUrl.getPath())); FileUtils.copyFile(new File(origUrl.getPath()), new File(fileUrl.getPath())); MapEnricher oper = new MapEnricher(); DelimitedFSLoader store = new DelimitedFSLoader(); // store.setFieldDescription("productCategory:INTEGER,productId:INTEGER"); store.setFileName(fileUrl.toString()); store.setSchema(//www . j a va 2s . com "{\"separator\":\",\",\"fields\": [{\"name\": \"productCategory\",\"type\": \"Integer\"},{\"name\": \"productId\",\"type\": \"Integer\"},{\"name\": \"mfgDate\",\"type\": \"Date\",\"constraints\": {\"format\": \"dd/MM/yyyy\"}}]}"); oper.setLookupFields(Arrays.asList("productId")); oper.setIncludeFields(Arrays.asList("productCategory", "mfgDate")); oper.setStore(store); oper.setup(null); CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<>(); @SuppressWarnings({ "unchecked", "rawtypes" }) CollectorTestSink<Object> tmp = (CollectorTestSink) sink; oper.output.setSink(tmp); oper.activate(null); oper.beginWindow(0); Map<String, Object> tuple = Maps.newHashMap(); tuple.put("productId", 3); tuple.put("channelId", 4); tuple.put("amount", 10.0); Kryo kryo = new Kryo(); oper.input.process(kryo.copy(tuple)); oper.endWindow(); oper.deactivate(); /* Number of tuple, emitted */ Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size()); Map<String, Object> emitted = sink.collectedTuples.iterator().next(); /* The fields present in original event is kept as it is */ Assert.assertEquals("Number of fields in emitted tuple", 5, emitted.size()); Assert.assertEquals("value of productId is 3", tuple.get("productId"), emitted.get("productId")); Assert.assertEquals("value of channelId is 4", tuple.get("channelId"), emitted.get("channelId")); Assert.assertEquals("value of amount is 10.0", tuple.get("amount"), emitted.get("amount")); /* Check if productCategory is added to the event */ Assert.assertEquals("productCategory is part of tuple", true, emitted.containsKey("productCategory")); Assert.assertEquals("value of product category is 1", 5, emitted.get("productCategory")); Assert.assertTrue(emitted.get("productCategory") instanceof Integer); /* Check if mfgDate is added to the event */ Assert.assertEquals("mfgDate is part of tuple", true, emitted.containsKey("productCategory")); Date mfgDate = (Date) emitted.get("mfgDate"); Assert.assertEquals("value of day", 1, mfgDate.getDate()); Assert.assertEquals("value of month", 0, mfgDate.getMonth()); Assert.assertEquals("value of year", 2016, mfgDate.getYear() + 1900); Assert.assertTrue(emitted.get("mfgDate") instanceof Date); }
From source file:com.datatorrent.contrib.enrich.FileEnrichmentTest.java
@Test public void testEnrichmentOperatorFixedWidthFSLoader() throws IOException, InterruptedException { URL origUrl = this.getClass().getResource("/fixed-width-sample.txt"); MapEnricher oper = new MapEnricher(); FixedWidthFSLoader store = new FixedWidthFSLoader(); store.setFieldDescription(/*from w w w . j a v a 2s. co m*/ "Year:INTEGER:4,Make:STRING:5,Model:STRING:40,Description:STRING:40,Price:DOUBLE:8,Date:DATE:10:\"dd:mm:yyyy\""); store.setHasHeader(true); store.setPadding('_'); store.setFileName(origUrl.toString()); oper.setLookupFields(Arrays.asList("Year")); oper.setIncludeFields(Arrays.asList("Year", "Make", "Model", "Price", "Date")); oper.setStore(store); oper.setup(null); CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<>(); @SuppressWarnings({ "unchecked", "rawtypes" }) CollectorTestSink<Object> tmp = (CollectorTestSink) sink; oper.output.setSink(tmp); oper.activate(null); oper.beginWindow(0); Map<String, Object> tuple = Maps.newHashMap(); tuple.put("Year", 1997); Kryo kryo = new Kryo(); oper.input.process(kryo.copy(tuple)); oper.endWindow(); oper.deactivate(); oper.teardown(); /* Number of tuple, emitted */ Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size()); Map<String, Object> emitted = sink.collectedTuples.iterator().next(); /* The fields present in original event is kept as it is */ Assert.assertEquals("Number of fields in emitted tuple", 5, emitted.size()); Assert.assertEquals("Value of Year is 1997", tuple.get("Year"), emitted.get("Year")); /* Check if Make is added to the event */ Assert.assertEquals("Make is part of tuple", true, emitted.containsKey("Make")); Assert.assertEquals("Value of Make", "Ford", emitted.get("Make")); /* Check if Model is added to the event */ Assert.assertEquals("Model is part of tuple", true, emitted.containsKey("Model")); Assert.assertEquals("Value of Model", "E350", emitted.get("Model")); /* Check if Price is added to the event */ Assert.assertEquals("Price is part of tuple", true, emitted.containsKey("Price")); Assert.assertEquals("Value of Price is 3000", 3000.0, emitted.get("Price")); Assert.assertTrue(emitted.get("Price") instanceof Double); /* Check if Date is added to the event */ Assert.assertEquals("Date is part of tuple", true, emitted.containsKey("Date")); Date mfgDate = (Date) emitted.get("Date"); Assert.assertEquals("value of day", 1, mfgDate.getDate()); Assert.assertEquals("value of month", 0, mfgDate.getMonth()); Assert.assertEquals("value of year", 2016, mfgDate.getYear() + 1900); Assert.assertTrue(emitted.get("Date") instanceof Date); }
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private boolean isSameYear(Date date0, Date date1) { return date0.getYear() == date1.getYear(); }