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

  • Home
  • SEARCH
  • 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 7277997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:48:56+00:00 2026-05-28T22:48:56+00:00

Is it possible to subtract time from a calendar? e.g. ….. Calendar DueTime =

  • 0

Is it possible to subtract time from a calendar?

e.g.

.....
Calendar DueTime      = Calendar.getInstance();
Calendar ReminderTime = Calendar.getInstance();

int ReminderMinute = 5;

DueTime.set(DueYear, DueMonth, DueDay, DueHour, DueMinute);

    Day   = Day   - reminderDays   ;
    Day   = Day   - (Week*7)       ;
    Month = Month - reminderMonths ;
    Year  = Year  - reminderYears  ;
    Hour  = Hour  - reminderHours  ;
    Minute= Minute- reminderMinutes;

    ReminderTime.set(Year, Month, Day, Hour, Minute  );
    ReminderTime.add(Calendar.DAY_OF_MONTH , - Day   );
    ReminderTime.add(Calendar.MONTH        , - Month );
    ReminderTime.add(Calendar.YEAR         , - Year  );
    ReminderTime.add(Calendar.HOUR         , - Hour  );
    ReminderTime.add(Calendar.MINUTE       , - Minute);

If the above is possible another question I would like to know is if…

reminderDays = 60;

Then would that go into the month before it as well?

Say its the 31st of the month that the due date is and the month before it has 30 days would the reminder day be the 1st of that month?


On another note that’s related:

I’m not sure if I am right or not but does a calendar instance store time in milliseconds?

e.g. 1 minute would be 600 milliseconds and an hour would be 36000 milliseconds

So if I did:

ReminderTime.add(Calendar.HOUR         , - 1  );

all it would be doing is adding -36000 to the total time stored in that calendar object

so if that’s true would doing:

ReminderTime.add(Calendar.DAY_OF_MONTH , - 60   );

result in it subtracting 51840000 milliseconds? Or would I need to change

ReminderTime.add(Calendar.DAY_OF_MONTH , - 60   );

to

ReminderTime.add(Calendar.DAY_OF_YEAR  , - 60   ); 

This would be after I call:

ReminderTime.set(Year, Month, Day, Hour, Minute  );

What I expect from this above is that my activity will calculate which day of the year that calendar object is and remove 51840000 milliseconds from it.


Can anyone help?

Three different questions here, separated by lines

  • 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-05-28T22:48:57+00:00Added an answer on May 28, 2026 at 10:48 pm

    Three questions, two statements which should enable you to answer them yourself.

    1) Yes you can subtract by adding a negative number as you have written.

    2) The fields carry, just like units,tens,hundreds do. So taking 60 off the DAY_OF_MONTH will carry into the previous month or months or year if necessary. It will adjust the calendar by 60 days

    P.S. 1 minute isn’t 60 milliseconds! It’s 60 x 1000 = 60,000 milliseconds

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

Sidebar

Related Questions

Is it possible to subtract a color from another one ? Example (correct me
Possible Duplicate: How can I subtract a day from a python date? I have
Is it possible to subtract the values in one NSMutableArray from those in another
Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Possible Duplicates: How to subtract a vector from each row of a matrix? How
Is it possible to subtract one DateTime from another and get the result in
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
I'm trying to capture keystrokes and replay them afterwards as equal as possible (time

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.