Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Calculate end date based on date selected

  1. #1
    Junior Member
    Join Date
    Sep 2022
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb Calculate end date based on date selected

    Hi guys,

    Anyone can please give me a hint on how to calculate end date?

    I have a project to do where I need to enter the vaccination date, then, the system should automatically calculate the remaining dates for second and third dosis.
    Last edited by hdiazr; September 19th, 2022 at 10:52 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Calculate end date based on date selected

    What classes are you allowed to use for this assignment? Java has classes that will help with this.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2022
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculate end date based on date selected

    I can use:

    Interfaces
    Abstract Classes
    Inheritance
    encapsulation
    Method Overloading

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Calculate end date based on date selected

    Have you looked at the Java SE classes that work with dates? Some of them have methods that will help.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Member
    Join Date
    Jun 2022
    Posts
    41
    Thanks
    1
    Thanked 3 Times in 2 Posts

    Default Re: Calculate end date based on date selected


  6. The Following User Says Thank You to AngleWyrm For This Useful Post:

    Norm (September 20th, 2022)

  7. #6
    Junior Member
    Join Date
    Sep 2022
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Calculate end date based on date selected

    I tried with a Jframe to calculate the years, months and dates. I want to create a section to show the dates based on those results. Any idea on how the code should like like? I'm thinking about an "if" function but I can't find any articles to calculate automatically.

    This is the code:

    private void btnCalculateActionPerformed(java.awt.event.ActionE vent evt) {
    // TODO add your handling code here:
    DateTimeFormatter date=DateTimeFormatter.ofPattern("dd/MM/yyyy");
    LocalDate fechanacimiento=LocalDate.parse(txtfechanacimiento .getText(), date);
    LocalDate fechaactual=LocalDate.now();

    Period periodo=Period.between(fechanacimiento, fechaactual);

    String resultado=("Tienes: "+periodo.getYears()+" Aņos, "+periodo.getMonths()+" Meses"+" y "+periodo.getDays()+" Dias");
    txtrespuesta.setText(resultado);


    }

  8. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Calculate end date based on date selected

    What problems are you having?
    What is that code supposed to do?
    What does it do now?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Splitting date string by date and time and assigning it to 2 variables
    By KaranSaxena in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 17th, 2014, 05:58 AM
  2. Java Date Format in Date Object
    By Ashr Raza in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 13th, 2012, 10:47 AM
  3. Replies: 1
    Last Post: July 22nd, 2011, 07:08 AM
  4. Getting date based on days past year
    By aussiemcgr in forum Java Theory & Questions
    Replies: 3
    Last Post: July 14th, 2010, 04:06 PM
  5. Copy folder based on latest date
    By ayonsoni in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: May 17th, 2010, 07:01 AM

Tags for this Thread