Example usage for org.joda.time LocalDate now

List of usage examples for org.joda.time LocalDate now

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:GUI.GUI.java

public GUI() {
    initComponents();//from ww w. jav  a  2 s .c  o m
    this.setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
    this.setTitle(Conection.getConfiguraciones().findConfiguraciones("nombreEmpresa").getValor());
    ImageIcon icono = new ImageIcon(getClass().getResource("/Recursos/IcoMotoParqueo.png"));
    this.setIconImage(icono.getImage());
    inicializarTablaDiario();
    SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy");
    Date fechaActual = LocalDate.now().toDate();
    Configuraciones fecha = Conection.getConfiguraciones().findConfiguraciones("fechaActual"),
            consecutivo = Conection.getConfiguraciones().findConfiguraciones("consecutivoDiario");
    if (fecha == null) {
        inicializarBase();
        fecha = Conection.getConfiguraciones().findConfiguraciones("fechaActual");
        consecutivo = Conection.getConfiguraciones().findConfiguraciones("consecutivoDiario");
    }
    if (fecha.getValor().compareTo(formato.format(fechaActual)) != 0) {
        fecha.setValor(formato.format(fechaActual));
        consecutivo.setValor("1");
    }
    try {
        Conection.getConfiguraciones().edit(fecha);
        Conection.getConfiguraciones().edit(consecutivo);
    } catch (Exception ex) {
        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
    }
    colaEntrada = new BasicEventList<>();
    DefaultEventListModel<String> modelo = GlazedListsSwing.eventListModel(colaEntrada);
    listaEspera.setModel(modelo);
    AutoCompleteDecorator.decorate(placaDiario, colaEntrada, false);
    mensuales = new BasicEventList<>();
    AutoCompleteDecorator.decorate(placaCobroMensual, mensuales, false);
    servidor = new ServidorTCP();
    Kryo kryo = servidor.getKryo();
    kryo.register(CupoJSON.class);
    kryo.register(SolicitudCliente.class);
    kryo.register(RespuestaServidor.class);
    kryo.register(ArrayList.class);
    servidor.start();
    try {
        servidor.bind(8051);
        servidor.addListener(new ServidorListener(this));
    } catch (IOException ex) {
        Logger.getLogger(GUI.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:hu.zsir.scoretable.AddPersonDialogController.java

License:Open Source License

/**
 * Save a person into the score table xml file and close the window.
 *///from ww w .j  ava2  s  .co m
@FXML
private void savePerson() {
    if (nameField.getText().isEmpty()) {
        warningText.setVisible(true);
    } else {
        Person newPerson = new Person(nameField.getText(), score, LocalDate.now().toString());
        ScoreTableUtils.addPerson(newPerson);
        cancel();
    }
}

From source file:info.matchingservice.dom.Actor.Person.java

License:Apache License

@Programmatic
public String validateNewDemand(final String needDescription, final LocalDate demandOrSupplyProfileStartDate,
        final LocalDate demandOrSupplyProfileEndDate, final Actor needOwner) {
    // if you are not the owner
    if (!needOwner.getOwnedBy().equals(currentUserName())) {
        return "NOT_THE_OWNER";
    }//from w w  w  .  j a  v  a  2s .  c om
    // if you have not Principal Role
    if (!((Person) needOwner).getIsPrincipal()) {
        return "ONE_INSTANCE_AT_MOST";
    }

    final LocalDate today = LocalDate.now();
    if (demandOrSupplyProfileEndDate != null && demandOrSupplyProfileEndDate.isBefore(today)) {
        return "ENDDATE_BEFORE_TODAY";
    }

    if (demandOrSupplyProfileEndDate != null

            &&

            demandOrSupplyProfileStartDate != null

            &&

            demandOrSupplyProfileEndDate.isBefore(demandOrSupplyProfileStartDate)

    ) {
        return "ENDDATE_BEFORE_STARTDATE";
    }

    return null;
}

From source file:info.matchingservice.dom.DemandSupply.Demand.java

License:Apache License

public String validateUpdateDemand(final String demandDescription, final String demandSummary,
        final String demandStory, final Blob demandAttachment, final LocalDate demandOrSupplyProfileStartDate,
        final LocalDate demandOrSupplyProfileEndDate) {
    final LocalDate today = LocalDate.now();
    if (demandOrSupplyProfileEndDate != null && demandOrSupplyProfileEndDate.isBefore(today)) {
        return "ENDDATE_BEFORE_TODAY";
    }//w w  w. j ava2 s.  c  o m

    if (demandOrSupplyProfileEndDate != null

            &&

            demandOrSupplyProfileStartDate != null

            &&

            demandOrSupplyProfileEndDate.isBefore(demandOrSupplyProfileStartDate)

    ) {
        return "ENDDATE_BEFORE_STARTDATE";
    }

    return null;
}

From source file:info.matchingservice.dom.DemandSupply.Supply.java

License:Apache License

public String validateUpdateSupply(final String supplyDescription,
        final LocalDate demandOrSupplyProfileStartDate, final LocalDate demandOrSupplyProfileEndDate) {
    final LocalDate today = LocalDate.now();
    if (demandOrSupplyProfileEndDate != null && demandOrSupplyProfileEndDate.isBefore(today)) {
        return "ENDDATE_BEFORE_TODAY";
    }// www .j a v  a  2 s  .c o m

    if (demandOrSupplyProfileEndDate != null

            &&

            demandOrSupplyProfileStartDate != null

            &&

            demandOrSupplyProfileEndDate.isBefore(demandOrSupplyProfileStartDate)

    ) {
        return "ENDDATE_BEFORE_STARTDATE";
    }

    return null;
}

From source file:info.matchingservice.dom.Match.ProfileMatchingService.java

License:Apache License

/**
 * //from  w ww . j av  a  2 s .com
 * @param demandProfileElement
 * @param supplyProfileElement
 * @return
 */
@Programmatic
public ProfileElementComparison getProfileElementAgeComparison(final ProfileElementNumeric demandProfileElement,
        final ProfileElementUsePredicate supplyProfileElement) {

    // return null if types are not as expected
    if (demandProfileElement.getProfileElementType() != ProfileElementType.AGE

            ||

            supplyProfileElement.getProfileElementType() != ProfileElementType.USE_AGE

    ) {
        return null;
    }

    Integer matchValue = 0;

    // When supply profile date of birth is meant to be used, indicated by supplyProfileElement.getUseAge() == true
    if (supplyProfileElement.getUseAge()) {

        // Make sure the supplyProfileElement belongs to a Person Profile of a Person with dateOfBirth property not null
        QueryDefault<Person> query = QueryDefault.create(Person.class, "findPersonUnique", "ownedBy",
                supplyProfileElement.getOwnedBy());

        if (container.firstMatch(query) != null

                &&

                container.firstMatch(query).getDateOfBirth() != null

                &&

                supplyProfileElement.getProfileElementOwner().getProfileType() == ProfileType.PERSON_PROFILE) {
            LocalDate supplyDateOfBirth = container.firstMatch(query).getDateOfBirth();
            new LocalDate();
            LocalDate toDay = LocalDate.now();
            Integer age = Years.yearsBetween(supplyDateOfBirth, toDay).getYears();
            Integer delta = Math.abs(age - demandProfileElement.getNumericValue());

            // The value of the match is 100 minus 5 x the difference in years between the demand age and the supplied age
            matchValue = 100 - 5 * delta;
            if (matchValue < 0) {
                matchValue = 0;
            }

            System.out.println("match from getProfileElementAgeComparison() in ProfileMatchingService.class:");
            System.out.println("owner username: " + container.firstMatch(query).getOwnedBy()
                    + " - dateOfBirth: " + container.firstMatch(query).getDateOfBirth());
            System.out.println(
                    "demanded age: " + demandProfileElement.getNumericValue() + " - matchValue: " + matchValue);
        }

    }

    ProfileElementComparison profileElementComparison = new ProfileElementComparison(
            demandProfileElement.getProfileElementOwner(), demandProfileElement, supplyProfileElement,
            supplyProfileElement.getProfileElementOwner(),
            supplyProfileElement.getProfileElementOwner().getActorOwner(), matchValue,
            demandProfileElement.getWeight());
    return profileElementComparison;

}

From source file:info.matchingservice.dom.Profile.Profile.java

License:Apache License

public String validateCreateTimePeriodElement(final LocalDate startDate, final LocalDate endDate,
        final Integer weight) {

    QueryDefault<ProfileElementTimePeriod> query = QueryDefault.create(ProfileElementTimePeriod.class,
            "findProfileElementOfType", "profileElementOwner", this, "profileElementType",
            ProfileElementType.TIME_PERIOD);

    if (container.firstMatch(query) != null) {

        return "ONE_INSTANCE_AT_MOST";

    }//ww  w . ja  v  a2  s  .  c om

    if (this.profileType != ProfileType.PERSON_PROFILE
            && this.profileType != ProfileType.ORGANISATION_PROFILE) {

        return "ONLY_ON_PERSON_OR_ORGANISATION_PROFILE";

    }

    if (this.getDemandOrSupply() != DemandOrSupply.DEMAND) {

        return "ONLY_ON_DEMAND";

    }

    //Date validation

    final LocalDate today = LocalDate.now();
    if (endDate != null && endDate.isBefore(today)) {
        return "ENDDATE_BEFORE_TODAY";
    }

    if (endDate != null

            &&

            startDate != null

            &&

            endDate.isBefore(startDate)

    ) {
        return "ENDDATE_BEFORE_STARTDATE";
    }

    return null;
}

From source file:info.matchingservice.dom.Profile.ProfileElementTimePeriod.java

License:Apache License

public String validateUpdateTimePeriod(LocalDate startDate, LocalDate endDate, Integer weight) {

    final LocalDate today = LocalDate.now();
    if (endDate != null && endDate.isBefore(today)) {
        return "ENDDATE_BEFORE_TODAY";
    }/*from   www  .j a va2 s  .  c  om*/

    if (endDate != null

            &&

            startDate != null

            &&

            endDate.isBefore(startDate)

    ) {
        return "ENDDATE_BEFORE_STARTDATE";
    }

    return null;
}

From source file:info.matchingservice.dom.Tags.TagHolders.java

License:Apache License

/**
 * This functions returns a tagHolder on a ProfileElement (actually a ProfileTagElement).
 * It checks if the tagCategory and the Tag already exists by testing on the tag(Category)Description.
 * If the tagCategory or Tag does not exist it will be created.
 * NOTE: make sure to test tagCategory in order not to accidentally create tagCategories!!
 * // ww w.j  a  v  a2 s . co  m
 * @param ownerElement
 * @param tagProposalWord
 * @param tagCategoryDescription
 * @param ownedBy
 * @return
 */
@Programmatic
public ProfileElement createTagHolder(final ProfileElement ownerElement, final String tagProposalWord,
        final String tagCategoryDescription, final String ownedBy) {
    Tag newTag;
    TagCategory newTagCategory;
    if (tagCategories.findTagCategoryMatches(tagCategoryDescription).isEmpty()) {
        //create new tagCategory
        newTagCategory = tagCategories.createTagCategory(tagCategoryDescription);
    } else {
        newTagCategory = tagCategories.findTagCategoryMatches(tagCategoryDescription).get(0);
    }
    if (tags.findTagAndCategoryMatches(tagProposalWord.toLowerCase(), newTagCategory).isEmpty()) {
        //make a new tag
        newTag = tags.createTag(tagProposalWord, newTagCategory);
    } else {
        newTag = tags.findTagAndCategoryMatches(tagProposalWord.toLowerCase(), newTagCategory).get(0);
    }

    final TagHolder newTagHolder = newTransientInstance(TagHolder.class);
    final UUID uuid = UUID.randomUUID();
    // administration of tag usage
    newTag.setDateLastUsed(LocalDate.now());
    if (newTag.getNumberOfTimesUsed() == null) {
        newTag.setNumberOfTimesUsed(1);
    } else {
        newTag.setNumberOfTimesUsed(newTag.getNumberOfTimesUsed() + 1);
    }
    // END administration of tag usage
    newTagHolder.setUniqueItemId(uuid);
    newTagHolder.setOwnerElement(ownerElement);
    newTagHolder.setTag(newTag);
    newTagHolder.setOwnedBy(ownedBy);
    persist(newTagHolder);

    return ownerElement;
}

From source file:info.matchingservice.dom.Tags.Tags.java

License:Apache License

@ActionLayout()
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
public TagCategory createTag(@ParameterLayout(named = "tagCategory") final TagCategory tagCategory,
        @ParameterLayout(named = "tagDescription", describedAs = "Omschrijving in zo min mogelijk woorden; liefst slechts een.", typicalLength = 80) final String tagDescription) {
    final Tag newTag = newTransientInstance(Tag.class);
    newTag.setTagDescription(tagDescription.toLowerCase());
    newTag.setTagCategory(tagCategory);// www .ja  va 2s  . c om
    newTag.setDisplCategory(tagCategory.title());
    newTag.setDateLastUsed(LocalDate.now());
    newTag.setNumberOfTimesUsed(0);
    persist(newTag);
    return tagCategory;
}