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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:36:08+00:00 2026-06-13T05:36:08+00:00

In my app you set the date/time with date/timePickers. SimpleDateFormat formatter = new SimpleDateFormat(yyyy-MM-dd

  • 0

In my app you set the date/time with date/timePickers.

 SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 Date datahora;
 datahora = (Date) formatter.parse(data);

I need to compare the time I set with the actual time of my phone. So I have tried this:

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date datahora;
String datatmp = formatter.format(new Date(0));
 try {
    datahora = (Date) formatter.parse(data);
    if(datahora <= datatmp)

but I do know its wrong because it says it cant check date > string but I can’t get to know how to check the actual time.

EDIT

LogCat

    10-08 20:14:07.453: E/AndroidRuntime(261): FATAL EXCEPTION: main
    10-08 20:14:07.453: E/AndroidRuntime(261): java.lang.IllegalStateException: get field slot from row 0 col -1 failed
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.database.CursorWindow.getString_native(Native Method)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.database.CursorWindow.getString(CursorWindow.java:329)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at com.example.mensagem.Mensagenssalvas$1.onItemClick(Mensagenssalvas.java:59)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.widget.AdapterView.performItemClick(AdapterView.java:284)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.widget.ListView.performItemClick(ListView.java:3382)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.os.Handler.handleCallback(Handler.java:587)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.os.Handler.dispatchMessage(Handler.java:92)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at         android.os.Looper.loop(Looper.java:123)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at java.lang.reflect.Method.invokeNative(Native Method)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at java.lang.reflect.Method.invoke(Method.java:521)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    10-08 20:14:07.453: E/AndroidRuntime(261):  at dalvik.system.NativeStart.main(Native Method)
  • 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-13T05:36:10+00:00Added an answer on June 13, 2026 at 5:36 am

    To get the current date/time you just create a new Date object.

    To compare dates you use Date.compareTo():

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date now = new Date();
    int difference = now.compareTo(formatter.parse(data));
    

    According to the docs, difference will be:

    the value 0 if the argument Date is equal to this Date; a value less
    than 0 if this Date is before the Date argument; and a value greater
    than 0 if this Date is after the Date argument.

    if (difference == 0) {
        // the dates are equal
    }
    else if (difference < 0) {
        // the date is before now
    }
    else {
        // the date is after now
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need set the date/time from Android programmatically, but I'm not having success! I
I am using NSDateFormatter to set my date in my iPhone app, and dates
I have to create an app in which I must set a date and
I'm trying to set up a date of birth helper in my Rails app
I need to get real-time information about Date and Time for my application. FYI,
In my app I have 2 buttons which opens a Time Dialog/Date Dialog and
I have an app set up where I convert an NSString into an array
I have a rails app set up as an OAuth2 provider (using Doorkeeper). The
I have terminal.app set to accept utf-8 and in bash I can type unicode
My configuration: app.configure(function(){ app.set('views', __dirname + '/views'); app.set('view engine', 'jade'); app.use(express.bodyParser()); app.use(express.cookieParser()); app.use(express.session({ secret:

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.