Example usage for org.joda.time YearMonthDay YearMonthDay

List of usage examples for org.joda.time YearMonthDay YearMonthDay

Introduction

In this page you can find the example usage for org.joda.time YearMonthDay YearMonthDay.

Prototype

public YearMonthDay() 

Source Link

Document

Constructs a YearMonthDay with the current date, using ISOChronology in the default zone to extract the fields.

Usage

From source file:com.moss.joda.swing.LiveDatePicker.java

License:Open Source License

public LiveDatePicker() {
    formats.add(DateTimeFormat.shortDate());
    formats.add(ISODateTimeFormat.date());
    formats.add(ISODateTimeFormat.basicDate());
    formats.add(DateTimeFormat.mediumDate());
    formats.add(DateTimeFormat.fullDate());
    formats.add(DateTimeFormat.longDate());

    //      p = new JXDatePicker();
    //      pButton = p.getComponent(1);
    //      p.getEditor().setVisible(false);

    pButton = new JButton("^");
    pButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Point p = pButton.getLocation();
            popup.show(pButton, 0, 0);/*from   w  w w.  j  a v a2  s . com*/

        }
    });
    popup.add(new DateSelectionListener() {
        public void dateSelected(YearMonthDay date) {
            setDate(date);
            fireSelection();
        }
    });

    t.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            handle();
        }

        public void insertUpdate(DocumentEvent e) {
            handle();
        }

        public void removeUpdate(DocumentEvent e) {
            handle();
        }

        void handle() {
            if (!uiUpdating) {
                String text = t.getText();
                YearMonthDay date = null;
                for (int x = 0; date == null && x < formats.size(); x++) {
                    DateTimeFormatter f = formats.get(x);
                    try {
                        date = f.parseDateTime(text).toYearMonthDay();
                    } catch (IllegalArgumentException e) {
                    }
                }
                value = date;
                if (date != null) {
                    popup.setDate(date);
                }
                fireSelection();
            }
        }

    });

    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.ipadx = 10;
    add(t, c);
    c.weightx = 0;
    c.ipadx = 0;
    //      c.insets.left = 5;
    add(pButton, c);

    setDate(new YearMonthDay());
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.administrativeOffice.candidacy.RegisterCandidate.java

License:Open Source License

@Atomic
public static void run(RegisterCandidacyBean candidacyBean) {
    check(RolePredicates.MASTER_DEGREE_ADMINISTRATIVE_OFFICE_PREDICATE);

    StateMachine.execute(candidacyBean.getCandidacy().getActiveCandidacySituation(),
            new StateBean(CandidacySituationType.REGISTERED.name()));

    final Registration registration = candidacyBean.getCandidacy().getRegistration();
    registration.setStartDate(//from  w w  w . j  ava  2  s  .  c  o m
            candidacyBean.getStartDate() != null ? candidacyBean.getStartDate() : new YearMonthDay());
    registration.setEnrolmentModelForCurrentExecutionYear(candidacyBean.getEnrolmentModel());
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.administrativeOffice.externalUnits.CreateExternalUnit.java

License:Open Source License

@Atomic
public static Unit run(final CreateExternalUnitBean externalUnitBean) throws FenixServiceException {

    if (externalUnitBean.getUnitType() == PartyTypeEnum.DEPARTMENT) {
        return DepartmentUnit.createNewOfficialExternalDepartmentUnit(externalUnitBean.getUnitName(),
                externalUnitBean.getUnitCode(), externalUnitBean.getParentUnit());
    } else {/*from   ww  w  . j  a va2 s. c o  m*/
        return new CreateUnit().run(externalUnitBean.getParentUnit(),
                new MultiLanguageString(Locale.getDefault(), externalUnitBean.getUnitName()), null, null,
                externalUnitBean.getUnitCode(), new YearMonthDay(), null, externalUnitBean.getUnitType(), null,
                null, null, null, null, null, null, null);
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.alumni.FormationManagement.java

License:Open Source License

protected AcademicalInstitutionUnit getFormationInstitution(final AlumniFormation formation) {
    AcademicalInstitutionUnit institutionUnit = formation.getInstitution();

    if (institutionUnit == null && formation.getInstitutionType() != null
            && (formation.getInstitutionType().equals(AcademicalInstitutionType.FOREIGN_INSTITUTION)
                    || formation.getInstitutionType().equals(AcademicalInstitutionType.OTHER_INSTITUTION))) {

        if (!StringUtils.isEmpty(formation.getForeignUnit())) {
            institutionUnit = UniversityUnit.createNewUniversityUnit(
                    new MultiLanguageString(formation.getForeignUnit()), null, null, null, new YearMonthDay(),
                    null, getParentUnit(formation), null, null, false, null);
            institutionUnit.setInstitutionType(formation.getInstitutionType());
        }/*  w  w  w.j ava  2  s.  c  o  m*/
    }
    return institutionUnit;
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.externalPerson.InsertExternalPerson.java

License:Open Source License

@Atomic
public static ExternalContract run(String personName, String organizationName) {
    final Unit organization = Unit.createNewNoOfficialExternalInstitution(organizationName);
    Person externalPerson = Person.createExternalPerson(personName, Gender.MALE, null, null, null, null, null,
            String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL);

    return new ExternalContract(externalPerson, organization, new YearMonthDay(), null);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.externalPerson.InsertExternalPerson.java

License:Open Source License

@Atomic
public static ExternalContract run(String personName, String organizationName, Country country) {
    final Unit organization = Unit.createNewNoOfficialExternalInstitution(organizationName, country);
    Person externalPerson = Person.createExternalPerson(personName, Gender.MALE, null, null, null, null, null,
            String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL);

    return new ExternalContract(externalPerson, organization, new YearMonthDay(), null);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.externalPerson.InsertExternalPerson.java

License:Open Source License

@Atomic
public static ExternalContract run(ServiceArguments arguments) throws FenixServiceException {

    ExternalContract storedExternalContract = null;
    String personName = arguments.getPersonName();
    Unit organization = arguments.getUnit();
    storedExternalContract = ExternalContract.readByPersonNameAddressAndInstitutionID(personName, null,
            organization.getExternalId());
    if (storedExternalContract != null) {
        throw new ExistingServiceException("error.exception.commons.ExternalContract.existingExternalContract");
    }/*from   ww w. j  a v  a 2s.c  o  m*/

    Person externalPerson = Person.createExternalPerson(personName, Gender.MALE, null, null, null, null, null,
            String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL);
    return new ExternalContract(externalPerson, organization, new YearMonthDay(), null);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.externalPerson.InsertExternalPerson.java

License:Open Source License

@Atomic
public static ExternalContract runWithOrganizationName(String name, String organizationName, String phone,
        String mobile, String email) throws FenixServiceException {

    final Unit organization = Unit.createNewNoOfficialExternalInstitution(organizationName);
    Person externalPerson = Person.createExternalPerson(name, Gender.MALE, null, phone, mobile, null, email,
            String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL);

    return new ExternalContract(externalPerson, organization, new YearMonthDay(), null);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.externalPerson.InsertExternalPerson.java

License:Open Source License

@Atomic
public static ExternalContract run(String name, Unit institutionLocation, String phone, String mobile,
        String email) throws FenixServiceException {

    Person externalPerson = Person.createExternalPerson(name, Gender.MALE, null, phone, mobile, null, email,
            String.valueOf(System.currentTimeMillis()), IDDocumentType.EXTERNAL);

    return new ExternalContract(externalPerson, institutionLocation, new YearMonthDay(), null);
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.commons.searchers.SearchAllActiveInternalUnits.java

License:Open Source License

@Override
protected Collection search(String value, int size) {
    Collection<UnitName> units = super.search(value, size);

    List<Unit> result = new ArrayList<Unit>();
    YearMonthDay now = new YearMonthDay();

    for (UnitName unitName : units) {
        Unit unit = unitName.getUnit();/* w w w . j  av a  2  s .c om*/
        if (unit.isActive(now)) {
            result.add(unit);
        }
    }

    return result;
}