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 8322393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:22:32+00:00 2026-06-08T23:22:32+00:00

I need to maintain a number of dates in my program and I’m doing

  • 0

I need to maintain a number of dates in my program and I’m doing that in the form of an array of Calendar objects.

To access it from several other classes, I plan to declare it in a separate class and import the array as a static import.

Now how can I set values for each of those objects? I’m able to initialize them and access them from the other class like this :

public static Calendar[] cal = new Calendar[]{
                                    Calendar.getInstance(),
                                    Calendar.getInstance()};

Now how do I set values to them?

I tried Calendar.getInstance().set(2012, 11, 10, 16, 30)
but i get an error with no suggestions.

So,

  1. Is static import the correct (or best) way to do this?
  2. How do I set values to it?
  • 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. Editorial Team
    Editorial Team
    2026-06-08T23:22:35+00:00Added an answer on June 8, 2026 at 11:22 pm

    The static import part is irrelevant, although frankly it’s not terribly nice having a publicly accessible writable field of a mutable array of mutable objects (calendars). A better approach would be to expose an ImmutableList<DateTime> using Guava for ImmutableList and Joda Time for DateTime. (Or possibly LocalDateTime) Anyway…

    You could use a static initializer block, but I’d probably just write a method instead:

    public static Calendar[] cal = createCalendars();
    
    private static Calendar[] createCalendars() {
        Calendar[] ret = new Calendar[2];
        ret[0] = Calendar.getInstance();
        ret[0].set(2012, 11, 10, 16, 30);
        ret[1] = Calendar.getInstance();
        ret[1].set(...);
        return ret;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a project that I need to maintain that talks to mysql via
We have an Excel application that I need to maintain that has shown his
I was advised in a previous question that I didn't need to maintain the
I need to print XML that I manipulated using groovy and maintain the attribute
I have two Tomcat servers that need to maintain a persistent connection to cut
I need to store a large table (several millions or rows) that contains a
I need to maintain a roster of connected clients that are very shortlived and
I need to maintain lists of 40 recent added, most popular/ most liked items
Folks, I need to maintain a C#/.Net desktop application. So, I need to set
Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need

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.