List of usage examples for org.joda.time LocalDate getDayOfMonth
public int getDayOfMonth()
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//from w w w . j a v a 2 s . co m * 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./*from w ww . j av a 2 s . c o 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; }//from www .ja v a 2 s.c om 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 *//*ww w. jav a 2s.c o m*/ 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(/*from ww w. j ava 2 s . c o m*/ 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:es.usc.citius.servando.calendula.fragments.HomeProfileMgr.java
License:Open Source License
public void init(View view, final Activity ctx) { this.context = ctx; this.rootView = view; preferences = PreferenceManager.getDefaultSharedPreferences(context); // Animation in = AnimationUtils.loadAnimation(ctx, android.R.anim.fade_in); // Animation out = AnimationUtils.loadAnimation(ctx, android.R.anim.fade_out); moods = ctx.getResources().getStringArray(R.array.moods); monthTv = (TextView) view.findViewById(R.id.month_text); dayTv = (TextView) view.findViewById(R.id.day_text); //clock = (CustomDigitalClock) view.findViewById(R.id.home_clock); bottomShadow = (ImageView) view.findViewById(R.id.bottom_shadow); profileInfo = view.findViewById(R.id.profile_info); blurMask = view.findViewById(R.id.blur_mask); santaContainer = view.findViewById(R.id.santa_container); santaImv = (ImageView) view.findViewById(R.id.image_santa); santaButton = (ImageButton) view.findViewById(R.id.santa_mode_button); santaButton.setImageDrawable(new IconicsDrawable(ctx, CommunityMaterial.Icon.cmd_pine_tree).sizeDp(36) .paddingDp(5).colorRes(R.color.white)); profileUsername = (TextView) view.findViewById(R.id.profile_username); profileContainer = (RelativeLayout) view.findViewById(R.id.profile_container); profileImageContainer = view.findViewById(R.id.profile_image_container); background = (ImageView) view.findViewById(R.id.image_switcher); modFabButton = (RoundedImageView) view.findViewById(R.id.mod_circle); moodImg = (ImageView) view.findViewById(R.id.mood_button); moodImg.setOnClickListener(new View.OnClickListener() { @Override//from w ww . j a va 2s . c om public void onClick(View v) { showMoodsDialog(); } }); background.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { updateBackground(); } }); updateModButton(); updateProfileInfo(); profileInfo.setVisibility(View.INVISIBLE); background.setVisibility(View.INVISIBLE); bottomShadow.setVisibility(View.INVISIBLE); boolean disableChristmasMode = preferences.getBoolean("disable_christmas_mode", false); LocalDate today = LocalDate.now(); if (!disableChristmasMode && today.getMonthOfYear() == 12 && (today.getDayOfMonth() >= 23 && today.getDayOfMonth() <= 31)) { try { int current = preferences.getInt("current_santa_image", 0); santaImv.setImageDrawable(new GifDrawable(ctx.getAssets(), images.get(current))); santaContainer.setVisibility(View.VISIBLE); blurMask.setAlpha(0.5f); santaButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (t != null) { t.cancel(); } t = Toast.makeText(context, R.string.christmas_remove_message, Toast.LENGTH_SHORT); t.show(); rotateChristmasImage(); } }); santaButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { santaContainer.setVisibility(View.GONE); preferences.edit().putBoolean("disable_christmas_mode", true).apply(); t = Toast.makeText(context, R.string.done, Toast.LENGTH_SHORT); t.show(); return true; } }); if (!preferences.getBoolean("christmas_message_shown_2016", false)) { showChristmasDialog(); preferences.edit().putBoolean("christmas_message_shown_2016", true).apply(); } santaMode = true; } catch (Exception e) { santaContainer.setVisibility(View.GONE); } } else { santaContainer.setVisibility(View.GONE); } Picasso.with(context).load("file:///android_asset/" + getBackgroundPath(ctx)).into(background); background.post(new Runnable() { @Override public void run() { bottomShadow.setVisibility(View.VISIBLE); background.setVisibility(View.VISIBLE); background.animate().alpha(1).setDuration(200); } }); background.postDelayed(new Runnable() { @Override public void run() { profileInfo.setVisibility(View.VISIBLE); profileInfo.setAlpha(0); profileInfo.animate().alpha(santaMode ? 0.5f : 1).setDuration(400); } }, 300); }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
private void setupStartEndDatePickers(View rootView) { if (schedule.start() == null) { schedule.setStart(LocalDate.now()); }/*from ww w . jav a 2 s . c o m*/ final LocalDate scheduleStart = schedule.start(); buttonScheduleStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Log.d(TAG, year + " " + monthOfYear); LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleStart(d); } }, scheduleStart.getYear(), scheduleStart.getMonthOfYear() - 1, scheduleStart.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LocalDate scheduleEnd = schedule.end() != null ? schedule.end() : scheduleStart.plusMonths(3); DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleEnd(d); } }, scheduleEnd.getYear(), scheduleEnd.getMonthOfYear() - 1, scheduleEnd.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Do you want this schedule to continue indefinitely?").setCancelable(true) .setPositiveButton(getString(R.string.dialog_yes_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { setScheduleEnd(null); } }) .setNegativeButton(getString(R.string.dialog_no_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); clearStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleStart(null); } }); clearEndButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleEnd(null); } }); setScheduleStart(schedule.start()); if (schedule.end() == null && isNew && hasEnd && daysToEnd > 0) { LocalDate end = schedule.start().plusDays(daysToEnd); setScheduleEnd(end); } else { setScheduleEnd(schedule.end()); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
@Override public void onRecurrenceSet(String s) { EventRecurrence event = new EventRecurrence(); LocalDate now = LocalDate.now(); Time startDate = new Time(Time.getCurrentTimezone()); startDate.set(now.getDayOfMonth(), now.getMonthOfYear(), now.getYear()); startDate.normalize(true);/*from w w w .j a va 2 s . co m*/ event.parse(s); event.setStartDate(startDate); Log.d(TAG, "OnRecurrenceSet: " + event.startDate); schedule.setRepetition(new RepetitionRule("RRULE:" + s)); setScheduleStart(schedule.start()); LocalDate end = schedule.end(); Log.d(TAG, "ICAL: " + schedule.rule().toIcal()); setScheduleEnd(end); Log.d(TAG, "ICAL: " + schedule.rule().toIcal()); ruleText.setText(getCurrentSchedule()); }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
void setScheduleEnd(LocalDate end) { if (end == null) { buttonScheduleEnd.setText(getString(R.string.never)); schedule.rule().iCalRule().setUntil(null); clearEndButton.setVisibility(View.INVISIBLE); } else {/* w w w . j a v a2 s . c om*/ DateValue v = new DateTimeValueImpl(end.getYear(), end.getMonthOfYear(), end.getDayOfMonth(), 0, 0, 0); schedule.rule().iCalRule().setUntil(v); buttonScheduleEnd.setText(end.toString(getString(R.string.schedule_limits_date_format))); clearEndButton.setVisibility(View.VISIBLE); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java
License:Open Source License
void setupStartEndDatePickers(View rootView) { if (schedule.start() == null) { schedule.setStart(LocalDate.now()); }//from w w w .j a v a2 s.c o m final LocalDate scheduleStart = schedule.start(); buttonScheduleStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { Log.d(TAG, year + " " + monthOfYear); LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleStart(d); } }, scheduleStart.getYear(), scheduleStart.getMonthOfYear() - 1, scheduleStart.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { LocalDate scheduleEnd = schedule.end() != null ? schedule.end() : scheduleStart.plusMonths(3); DatePickerDialog dpd = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { LocalDate d = new LocalDate(year, monthOfYear + 1, dayOfMonth); setScheduleEnd(d); } }, scheduleEnd.getYear(), scheduleEnd.getMonthOfYear() - 1, scheduleEnd.getDayOfMonth()); dpd.show(); } }); buttonScheduleEnd.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setMessage("Do you want this schedule to continue indefinitely?").setCancelable(true) .setPositiveButton(getString(R.string.dialog_yes_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { setScheduleEnd(null); } }) .setNegativeButton(getString(R.string.dialog_no_option), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); return true; } }); clearStartButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleStart(null); } }); clearEndButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setScheduleEnd(null); } }); setScheduleStart(schedule.start()); setScheduleEnd(schedule.end()); }