Java retrieve and compare two dates plus time - java

Basically I want to ask the user for a date and time of departure then ask the user for time of arrival to compare and get duration. I was wondering what kind of method of input would be good for this input. I was thinking either a multi drop down box or some kind of scrolling bar type deal. Can any one give me and suggestion on a good input method and what it is called? That does not require adding components or just asking the user to type it in, something simple.

Yes, using two dropdown controls (or a calendar control for the date) is a common way of handling this in a GUI.
Search Google for ideas, for example amtrak.com, or any travel website really.

Related

I cant decide the best way to store strings for what I'm trying to achieve

I have been given the task to make a text based game and I am opting to go with a dating sim. I have all the dialogue written out but I am stuck on where I would store the dialogue. At first I thought of just making a lot of if statement ex( if you pick this option it takes you to this) but this seems to be really inefficient. So I dont know whether it would be better to have them in an array or array list and just go to that specific place in that array. Sorry if that was confusing that was some background I guess im asking what is the best way to store strings in a game revolving around conversations.
Your question is too vague but of course, other people before has been working on it.
A good starting point (with lot of references) could be, "Gameplay Design Patterns for Game Dialogues" Jenny Brusk and Staffan Björk
On the other hand, Dialog Trees (and here and here) is a way to store dialogs but can work or not for your specific needs.

How to set task to run after a certain time in the day?

Right now I have a class that writes reservations for a resort into a .dat file
Each day I would like to automatically check them out if the current date is more than or equal their checkout date.
So if its 12:40 in the day, then the function would automatically check out anyone whose checkout date is today. If its 11:40, then no.
Im really hoping for a non-TimerTask implementation since this method is within another class and Im restricted to it.
I currently use the Calender Class for dates.
Do you want to auto-checkout if someone reserves after 12.00? Which means the "first customer after noon" is the trigger for the checkout? If not, you will have to use a timer of some sort.
If you have enough customers to use the customer-driven auto-checkout, it's just a matter of checking if it's after 12.00...?

How to specify a range of valid values in a Java GUI

I am creating an IMDB application which displays and organizes movies found on you computer (by looking up the metadata via an IMDB API).
In my search panel I want to give the user the option of looking for movies that were released in a specific range of years (e.g. between 1990 and 2005). Currently I use for this two JSpinners, one for the minimum year and one for the maximum year and use cross validation to check whether maxYear >= minYear && minYear <= maxYear However I don't think this is very user-friendly.
What I would like is a JSlider with two knobs, one for min and one for max. Is this possible? Do you have any other ideas on how to make this interface more user-friendly?
This looks promising: Creating a Java Swing range slider
And here's another example that I think came from the old Tame examples: MThumbSlider
You could have two JTextFields, and just let the user type the minimum and maximum years.
Otherwise, two JSpinners is another choice. Developing a custom component that your users have never seen is not user friendly.
You can cross connect the two JSpinners so that it's impossible for the user to enter a minimum year greater than a maximum year. I've not done this, so I don't have a code example to show you.

java - how to make decision based on string

If you have a string like this volume-7,notcontact-xxxx,not_lightlevel-1280.0, and this string could vary with other options, like vibrate, light level, screen brightness etc...but the formatting would be the same...(setting-value,setting-value...)
What would be the best way to make a decision based on the current information you have on these settings? (i.e return true or false by checking the predefined string against the current contextual information I have)
So let's say you have the current contextual information...i.e the current volume level, vibrator setting, the light level, screen brightness, etc etc and you want to compare it against a pre-defined string such as the I wrote above,
how would you do it?
Would you parse the string and check for every single possibility? while doable, it doesn't sound very appealing..
Could I use decision trees? If yes, could someone tell me how I would go about it?
Thanks
Parsing it into a HashMap would be my first thought.
You can also use a POJO if you know all the keys in advance. (You'll still have to populate the fields using reflection but you are guaranteed compile time type safety for all the other operations.)
(I might be completely misunderstanding your question, but I can't find any connection between the problem you described and decision trees.)

User matching with current data

I have a database full of two different types of users (Mentors and Mentees), whereby I want the second group (Mentees) to be able to "search" for people in the first group (Mentors) who match their profile. Mentors and Mentees can both go in and change items in their profile at any point in time.
Currently, I am using Apache Mahout for the user matching (recommender.mostSimilarIDs()). The problem I'm running into is that I have to reload the user data every single time anyone searches. By itself, this doesn't take that long, but when Mahout processes the data it seems to take a very long time (14 minutes for 3000 Mentors and 3000 Mentees). After processing, matching takes mere seconds. I also get the same INFO message over and over again while it's processing ("Processed 2248 users"), while looking at the code shows that the message should only be outputted every 10000 users.
I'm using the GenericUserBasedRecommender and the GenericDataModel, along with the NearestNUserNeighborhood, AveragingPreferenceInferrer and PearsonCorrelationSimilarity. I load mentors from the database, add the mentee to the list of POJOs and convert them to a FastByIDMap to give to the DataModel.
Is there a better way to be doing this? The product owner needs the data to be current for every search.
(I'm the author.)
You shouldn't need to ask it to reload the data every time, why's that?
14 minutes sounds way, way too long to load such a small amount of data too, something's wrong. You might follow up with more info at user#mahout.apache.org.
You are seeing log messages from a DataModel, which you can disable in your logging system of choice. It prints one final count. This is nothing to worry about.
I would advise you against using a PreferenceInferrer unless you absolutely know you want it. Do you actually have ratings here? I might suggest LogLikelihoodSimilarity if not.

Categories