List of usage examples for org.joda.time LocalDate getMonthOfYear
public int getMonthOfYear()
From source file:de.jpaw.bonaparte.util.DayTime.java
License:Apache License
/** Converts the day portion of a LocalDate or localDateTime into a number in the format YYYYMMDD. */ static public int dayAsInt(LocalDate when) { return when.getDayOfMonth() + 100 * when.getMonthOfYear() + 10000 * when.getYear(); }
From source file:de.l3s.content.timex.extracting.utils.DateUtil.java
License:Apache License
/** * //from w w w . j ava 2 s . c o m * @param content * @param url * @param docid * @return * @throws ParseException */ public LocalDate extractDate(String[] content_lines, String url, String docId) throws ParseException { LocalDate extractedUrlDate = null; LocalDate extractedDocIdDate = null; LocalDate extractedContentDate = null; // extract date from content extractedContentDate = extractDateFromContent(content_lines[0]); if (extractedContentDate == null && content_lines.length > 1) extractedContentDate = extractDateFromContent(content_lines[1]); if (extractedContentDate == null) { //extract date from blog url extractedUrlDate = extractDateFromURL(url); //extract date from docid extractedDocIdDate = LocalDate.parse(docId.substring(7, 15), dateFormat); if (extractedUrlDate != null && extractedUrlDate.getMonthOfYear() == extractedDocIdDate.getMonthOfYear() && extractedUrlDate.getYear() == extractedDocIdDate.getYear() && extractedUrlDate.getDayOfMonth() == 15) { return extractedDocIdDate; } //case url contains exact date yyyyMMdd else if (extractedUrlDate != null && extractedUrlDate.getDayOfMonth() != 15) return extractedUrlDate; else if (extractedUrlDate == null) return extractedDocIdDate; else return extractedUrlDate; } else { return extractedContentDate; } }
From source file:de.sub.goobi.helper.DateUtils.java
License:Open Source License
/** * The function sameMonth() compares two LocalDate objects in regard to the * question whether their two dates reside in the same month of the calendar * system presumed. Two dates are considered to be in the same month exactly * if both their year and month of year fields are equal. * * @param compared//from ww w .j av a 2 s . c o m * date to compare against * @param comparee * date to compare, may be null * @return whether the two dates are in the same month */ public static boolean sameMonth(LocalDate compared, LocalDate comparee) { if (!sameYear(compared, comparee)) { return false; } return compared.getMonthOfYear() == comparee.getMonthOfYear(); }
From source file:de.sub.goobi.helper.tasks.CreateNewspaperProcessesTask.java
License:Open Source License
/** * Creates a logical structure tree in the process under creation. In the * tree, all issues will have been created. Presumption is that never issues * for more than one year will be added to the same process. * * @param newProcess/* w w w. j a v a 2s . c om*/ * process under creation * @param issues * issues to add * @param publicationRun * verbal description of the course of appearance */ private void createLogicalStructure(ProzesskopieForm newProcess, List<IndividualIssue> issues, String publicationRun) { // initialise Prefs ruleset = serviceManager.getRulesetService() .getPreferences(newProcess.getProzessKopie().getRuleset()); DigitalDocument document; try { document = newProcess.getFileformat().getDigitalDocument(); } catch (PreferencesException e) { throw new RuntimeException(e.getMessage(), e); } DocStruct newspaper = document.getLogicalDocStruct(); // try to add the publication run addMetadatum(newspaper, "PublicationRun", publicationRun, false); // create the year level DocStruct year = createFirstChild(newspaper, document, ruleset); String theYear = Integer.toString(issues.get(0).getDate().getYear()); addMetadatum(year, MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, theYear, true); // create the month level Map<Integer, DocStruct> months = new HashMap<>(); Map<LocalDate, DocStruct> days = new HashMap<>(488); for (IndividualIssue individualIssue : issues) { LocalDate date = individualIssue.getDate(); Integer monthNo = date.getMonthOfYear(); if (!months.containsKey(monthNo)) { DocStruct newMonth = createFirstChild(year, document, ruleset); addMetadatum(newMonth, MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, monthNo.toString(), true); addMetadatum(newMonth, year.getType().getName(), theYear, false); addMetadatum(newMonth, MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, monthNo.toString(), false); months.put(monthNo, newMonth); } DocStruct month = months.get(monthNo); // create the day level if (!days.containsKey(date)) { DocStruct newDay = createFirstChild(month, document, ruleset); addMetadatum(newDay, MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, Integer.toString(date.getDayOfMonth()), true); addMetadatum(newDay, year.getType().getName(), theYear, false); addMetadatum(newDay, month.getType().getName(), Integer.toString(date.getMonthOfYear()), false); addMetadatum(newDay, MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, Integer.toString(date.getDayOfMonth()), false); days.put(date, newDay); } DocStruct day = days.get(date); // create the issue DocStruct issue = createFirstChild(day, document, ruleset); String heading = individualIssue.getHeading(); if ((heading != null) && (heading.trim().length() > 0)) { addMetadatum(issue, issue.getType().getName(), heading, true); } addMetadatum(issue, year.getType().getName(), theYear, false); addMetadatum(issue, month.getType().getName(), Integer.toString(date.getMonthOfYear()), false); addMetadatum(issue, day.getType().getName(), Integer.toString(date.getDayOfMonth()), false); addMetadatum(issue, MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, heading, false); } }
From source file:de.sub.goobi.helper.tasks.ExportNewspaperBatchTask.java
License:Open Source License
/** * Inserts a reference (METS pointer (mptr) URL) for an issue on a given * date into an act./* www .j a v a2 s.co m*/ * * @param act * act in whose logical structure the pointer is to create * @param ruleset * rule set the act is based on * @param date * date of the issue to create a pointer to * @param metsPointerURL * URL of the issue * @throws TypeNotAllowedForParentException * is thrown, if this DocStruct is not allowed for a parent * @throws MetadataTypeNotAllowedException * if the DocStructType of this DocStruct instance does not * allow the MetadataType or if the maximum number of Metadata * (of this type) is already available * @throws TypeNotAllowedAsChildException * if a child should be added, but it's DocStruct type isn't * member of this instance's DocStruct type */ private void insertIssueReference(DigitalDocument act, Prefs ruleset, LocalDate date, String metsPointerURL) throws TypeNotAllowedForParentException, TypeNotAllowedAsChildException, MetadataTypeNotAllowedException { DocStruct year = getOrCreateChild(act.getLogicalDocStruct(), yearLevelName, MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, Integer.toString(date.getYear()), MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, act, ruleset); DocStruct month = getOrCreateChild(year, monthLevelName, MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, Integer.toString(date.getMonthOfYear()), MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, act, ruleset); DocStruct day = getOrCreateChild(month, dayLevelName, MetsModsImportExport.CREATE_ORDERLABEL_ATTRIBUTE_TYPE, Integer.toString(date.getDayOfMonth()), MetsModsImportExport.CREATE_LABEL_ATTRIBUTE_TYPE, act, ruleset); DocStruct issue = day.createChild(issueLevelName, act, ruleset); issue.addMetadata(MetsModsImportExport.CREATE_MPTR_ELEMENT_TYPE, metsPointerURL); }
From source file:de.symeda.sormas.ui.utils.DateFilter.java
License:Open Source License
@Override public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException { if (DataHelper.isNullOrEmpty(filterString)) { return true; }/* ww w . ja va2s .c o m*/ Date date = (Date) item.getItemProperty(propertyId).getValue(); if (date == null) { return false; } Date[] dateBounds = DateHelper.findDateBounds(filterString); if (dateBounds != null) { if (!date.before(dateBounds[0]) && !date.after(dateBounds[1])) { // not outside bounds return true; } } Integer[] dayAndMonth = DateHelper.findDatePrefix(filterString); if (dayAndMonth != null) { LocalDate localDate = new LocalDate(date); if (dayAndMonth[0] != null) { if (localDate.getDayOfMonth() != dayAndMonth[0]) { // day does not match return false; } } if (dayAndMonth[1] != null) { if (localDate.getMonthOfYear() != dayAndMonth[1]) { // month does not match return false; } } // available data matches return true; } return false; }
From source file:divconq.lang.BigDateTime.java
License:Open Source License
/** * @param date translates into BigDateTime, assumes ISOChronology *///from www .jav a2 s. com public BigDateTime(LocalDate date) { if (date == null) return; this.year = 50000000000L + date.getYear(); // ISO says 1 BCE = 0, 2 BCE = -1, etc this.month = date.getMonthOfYear(); this.day = date.getDayOfMonth(); }
From source file:edu.harvard.med.iccbl.screensaver.reports.icbg.AssayInfoProducer.java
License:Open Source License
public AssayInfo getAssayInfoForScreen(Screen screen) throws FileNotFoundException { AssayInfo assayInfo = new AssayInfo(); assayInfo.setAssayName("ICCBL" + screen.getFacilityId()); assayInfo.setProtocolDescription(screen.getTitle()); assayInfo.setPNote(screen.getSummary()); assayInfo.setInvestigator(/* w w w .java 2 s . com*/ screen.getLabHead() == null ? "" : screen.getLabHead().getLastName().toUpperCase()); String assayCategoryText = ""; for (String keyword : screen.getKeywords()) { assayCategoryText += keyword.toUpperCase() + " "; } if (assayCategories != null) { assayInfo.setAssayCategory(assayCategories.get(screen.getFacilityId())); } else { assayCategoryText += screen.getSummary().toUpperCase(); setAssayCategory(assayInfo, assayCategoryText); } LocalDate assayDate = screen.getDateCreated().toLocalDate(); for (StatusItem statusItem : screen.getStatusItems()) { LocalDate statusItemDate = statusItem.getStatusDate(); if (assayDate == null || assayDate.compareTo(statusItemDate) < 0) { assayDate = statusItemDate; } } assayInfo.setAssayDate( assayDate.getMonthOfYear() + "/" + assayDate.getDayOfMonth() + "/" + (assayDate.getYear())); assert assayDate.getYear() >= 1900 : "year should include century"; return assayInfo; }
From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.SemLeidmiseAbimeetodid.java
License:Open Source License
/** * Tagastab kuupaevale vastava kvartali lipiku. *//*from ww w . j a v a 2 s. co m*/ public static String getQuarterOfYear(LocalDate date) { int month = date.getMonthOfYear(); if (1 <= month && month <= 3) { return "Q1"; } if (4 <= month && month <= 6) { return "Q2"; } if (7 <= month && month <= 9) { return "Q3"; } if (10 <= month && month <= 12) { return "Q4"; } return null; }
From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.SemLeidmiseAbimeetodid.java
License:Open Source License
/** * Tagastab kuupaevale vastava aastaaja lipiku. *//*from w w w.j a v a 2 s . co m*/ public static String getSeason(LocalDate date) { int month = date.getMonthOfYear(); if (12 <= month || month <= 2) { return "WI"; } if (3 <= month && month <= 5) { return "SP"; } if (6 <= month && month <= 8) { return "SU"; } if (9 <= month && month <= 11) { return "FA"; } return null; }