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.
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.
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.
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.
I can use:
Interfaces
Abstract Classes
Inheritance
encapsulation
Method Overloading
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.
Norm (September 20th, 2022)
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);
}
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.