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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:15:52+00:00 2026-06-01T20:15:52+00:00

I am trying to make a method where you can enter the arguments of,

  • 0

I am trying to make a method where you can enter the arguments of, the current month and the amount of months you want to trace back, and convert all of this into days. For example, if the current month was January and I wanted convert the last 5 months into days the answer would be 153. I have the following information for one to use.

    private Calendar cal;

    private int currentMonth;

    private final int JANUARY = 31;
    private final int FEBRUARY = 28;
    private final int MARCH = 31;
    private final int APRIL = 30;
    private final int MAY = 31;
    private final int JUNE = 30;
    private final int JULY = 31;
    private final int AUGUST = 31;
    private final int SEPTEMBER = 30;
    private final int OCTOBER = 31;
    private final int NOVEMBER = 30;
    private final int DECEMBER = 31;

    public Constructor(){
        cal = new GregorianCalendar();
        currentMonth = cal.get(Calendar.MONTH);
    }


    private int convertMonthsToDays(int currentMonth, int months){
        int days;
        return days;
}
  • 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-01T20:15:54+00:00Added an answer on June 1, 2026 at 8:15 pm

    Use this code for what you want

    package test;
    
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    
    import org.hibernate.Criteria;
    import org.hibernate.Session;
    import org.hibernate.criterion.Restrictions;
    
    import com.ibm.icu.util.Calendar;
    import com.ibm.icu.util.GregorianCalendar;
    import com.mPower.fw.dao.ClassMaster;
    import com.mPower.fw.impl.DaoServiceIMPL;
    import com.mPower.fw.util.hibernateUtil;
    
    public class runT {
    
        public static void main(String[] args) throws IOException {
            try{
                Calendar calendar = new GregorianCalendar();
                int CURRENT_MONTH = 0;
                int MONTH_BACK = 5;
    
                int totalDays = 0;
    
            calendar.set(Calendar.MONTH, CURRENT_MONTH);
    
                for(int i=0;i<MONTH_BACK;i++){
                    totalDays += calendar.getMaximum(java.util.Calendar.DAY_OF_MONTH);
                    calendar.add(Calendar.MONTH, -1);
                }
    
                System.out.println(totalDays);
    
            }catch(Exception e){
                e.printStackTrace();
            }
        }
    
    }
    

    use calendar.add(Calendar.MONTH, -1); for Month back.

    use calendar.add(Calendar.MONTH, 1); for month forward.

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

Sidebar

Related Questions

I have been trying to make a method where the user can input a
I am trying to make a generic method that can accept any object, in
I'm trying to make the create method private/protected for an ActiveRecord model. I want
I am trying to make a method that will go through a list of
I'm trying to make a method that will tell me weather or not it
I am trying to make a method that tests to see if 3 lengths
I'm trying to make a method that will draw a cube with a specified
I am trying to make a call to a Parent class method from a
I have a huge problem with this method im trying to make. I have
I'm trying to let a user "make his own service". most direct method I

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.