Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 35807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:17:38+00:00 2026-05-10T14:17:38+00:00

This is a nasty one for me… I’m a PHP guy working in Java

  • 0

This is a nasty one for me… I’m a PHP guy working in Java on a JSP project. I know how to do what I’m attempting through too much code and a complete lack of finesse.

I’d prefer to do it right. Here is the situation:

I’m writing a small display to show customers what days they can water their lawns based on their watering group (ABCDE) and what time of year it is. Our seasons look like this: Summer (5-1 to 8-31) Spring (3-1 to 4-30) Fall (9-1 to 10-31) Winter (11-1 to 2-28)

An example might be:

If I’m in group A, here would be my allowed times: Winter: Mondays only Spring: Tues, Thurs, Sat Summer: Any Day Fall: Tues, Thurs, Sat

If I was writing this in PHP I would use arrays like this:

//M=Monday,t=Tuesday,T=Thursday.... etc $schedule['A']['Winter']='M'; $schedule['A']['Spring']='tTS'; $schedule['A']['Summer']='Any'; $schedule['A']['Fall']='tTS'; $schedule['B']['Winter']='t'; 

I COULD make the days arrays (array(‘Tuesday’,’Thursday’,’Saturday’)) etc, but it is not necessary for what I’m really trying to accomplish.

I will also need to setup arrays to determine what season I’m in:

$seasons['Summer']['start']=0501; $seasons['Summer']['end']=0801; 

Can anyone suggest a really cool way to do this? I will have today’s date and the group letter. I will need to get out of my function a day (M) or a series of days (tTS), (Any).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:17:39+00:00Added an answer on May 10, 2026 at 2:17 pm

    You could do essentially the same code with Hashtables (or some other Map):

    Hashtable<String, Hashtable<String, String>> schedule     = new Hashtable<String, Hashtable<String, String>>(); schedule.put('A', new Hashtable<String, String>()); schedule.put('B', new Hashtable<String, String>()); schedule.put('C', new Hashtable<String, String>()); schedule.put('D', new Hashtable<String, String>()); schedule.put('E', new Hashtable<String, String>());  schedule.get('A').put('Winter', 'M'); schedule.get('A').put('Spring', 'tTS'); // Etc... 

    Not as elegant, but then again, Java isn’t a dynamic language, and it doesn’t have hashes on the language level.

    Note: You might be able to do a better solution, this just popped in my head as I read your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's also 'paredit. The cheat sheet shows you all the… May 11, 2026 at 11:31 pm
  • Editorial Team
    Editorial Team added an answer From the sounds of it you may be (a) running… May 11, 2026 at 11:31 pm
  • Editorial Team
    Editorial Team added an answer According to the XML spec, for regular content and markup:… May 11, 2026 at 11:31 pm

Related Questions

This is a nasty one for me... I'm a PHP guy working in Java
Maybe this is just a stupid idea, that's why I toss it in here:
Can anyone tell me what this cast has for effect (besides setting happyNumber to
I recently wrote a program that used a simple producer/consumer pattern. It initially had
One advantage of PNG is full alpha transparency, which allows you to have smooth

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.