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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:11:16+00:00 2026-05-28T17:11:16+00:00

I have this date object: SimpleDateFormat df = new SimpleDateFormat(yyyy-mm-dd HH:mm); Date d1 =

  • 0

I have this date object:

SimpleDateFormat df = new SimpleDateFormat("yyyy-mm-dd HH:mm");
Date d1 = df.parse(interviewList.get(37).getTime());

value of d1 is Fri Jan 07 17:40:00 PKT 2011

Now I am trying to add 10 minutes to the date above.

Calendar cal = Calendar.getInstance();
cal.setTime(d1);
cal.add(Calendar.MINUTE, 10);
String newTime = df.format(cal.getTime());

Value of newTime changes to 2011-50-07 17:50
but it should be 07-01-2011 17:50.

It adds minutes correctly but it also changes month, don’t know why!

  • 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-28T17:11:17+00:00Added an answer on May 28, 2026 at 5:11 pm

    The issue for you is that you are using mm. You should use MM. MM is for month and mm is for minutes. Try with yyyy-MM-dd HH:mm

    Other approach:

    It can be as simple as this (other option is to use joda-time)

    static final long ONE_MINUTE_IN_MILLIS=60000;//millisecs
    
    Calendar date = Calendar.getInstance();
    long t= date.getTimeInMillis();
    Date afterAddingTenMins=new Date(t + (10 * ONE_MINUTE_IN_MILLIS));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to get a new Date object with a SimpleDateFormat applied to it.
I have the following code to handle date SimpleDateFormat formatter = new SimpleDateFormat(dd/MM/yyyy HH:mm:ss
I have this: var date = new DateTime(2009, 12, 5); ... ... and need
I have this code: Date now = new Date(); // the string is in
I have this SP USE [TestDB] GO /****** Object: StoredProcedure [dbo].[sp_test] Script Date: 06/12/2010
If i have a File object how can i get the lastModified() date of
I have string Tue Nov 12 2010,I want to parse it in java.util.Date object.
I parse this date 22/11/11 into a DateTime object called s. When I do
i have this date's & Time's: date1: 10/04/2010 - Time: 08:09 date2: 11/04/2010 -
I have this routine that calculates the seconds-to-date for a struct tm . On

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.