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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:00:47+00:00 2026-06-19T03:00:47+00:00

I try to get the date of yesterday. So I write the next function:

  • 0

I try to get the date of yesterday. So I write the next function:

public  String getYestrday() {
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    return dateFormat.format(date.getDate() - 1);
}

But it gives me the next warning:

The method getDate() from the type Date is deprecated

and it doesn’t do it work.

Thank you for your help.

  • 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-19T03:00:47+00:00Added an answer on June 19, 2026 at 3:00 am

    Date#getDate() is a deprecated method after JDK 1.1. You should be using Calendar class instead to manipulate dates.

    From API:

    Prior to JDK 1.1, the class Date had two additional functions. It
    allowed the interpretation of dates as year, month, day, hour, minute,
    and second values. It also allowed the formatting and parsing of date
    strings. Unfortunately, the API for these functions was not amenable
    to internationalization. As of JDK 1.1, the Calendar class should be
    used to convert between dates and time fields and the DateFormat class
    should be used to format and parse date strings. The corresponding
    methods in Date are deprecated.

    It is also clearly documented in the API using Date#getDate() to use Calendar#get(Calendar.DATE);

    Deprecated. As of JDK version 1.1, replaced by
    Calendar.get(Calendar.DAY_OF_MONTH)

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1);
    return dateFormat.format(cal.getTime());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to convert date to string I get this error. So how
I try to get the last modification date of a file: NSFileManager *fm =
I try to get this following url using the downloadURL function as follows: http://www.ncbi.nlm.nih.gov/nuccore/27884304
I try to get and manage date with NSDateFormatter but how to make it
Here is what i try to get. i need the date format in php
i get date from xml in this format: 7/16/2010 (mm/dd/yyyy) i have in my
This is my try to get records below the date: SELECT Title, XXXX from
I try to get all date/time format pattern in GWT, using DateTimeFormat.PredefinedFormat to get
I will try everything but not working this( dd/MM/yyyy ) date format, this always
I have a little problem with timestamp. When i try to get current date

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.