I need help with java. Need to calculate some data.

So I have two questions i'm trying to answer and calculate.
1. What is the date of birth for your pet?
2. When was it vaccinated?

The answers should be dates. Their might be a few more questions.

The calculation should give you and answer saying yes your in compliance or
no. Can I do something that specific before I waste my time trying to
figure out the code for it?

Also, if this can be done with java, is there a site where I can figure the code out or can someone assist me with the code? Any and all help appreciated.



2 Replies
Matthew Bibby

Okay, so you want to check if the pet is more than 3 months old and if it had it's vaccinations at 12 weeks or later. Based on these details, this should give you a good starting point:

var player = GetPlayer();
var dob = player.GetVar("dob");
var vaccination = player.GetVar("vaccination");
var date0 = new Date();
var date1 = new Date(dob);
var date2 = new Date(vaccination);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
if (diffDays < 84) {var dobVac = false;} else {dobVac = true;}
var timeDiff2 = Math.abs(date0.getTime() - date1.getTime());
var diffDays2 = Math.ceil(timeDiff2 / (1000 * 3600 * 24));
if (diffDays2 < 90) {var dobNow = false;} else {dobNow = true;}
console.log(dobNow, dobVac);

Here is the source file. 

Here is a demo.

It is still a bit buggy, but hopefully this helps.