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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:04:36+00:00 2026-06-16T04:04:36+00:00

I want to check if a given DateTime is before or after current DateTime.

  • 0

I want to check if a given DateTime is before or after current
DateTime. I was converting input time and current time to a common
time zone (say UTC) and comparing DateTime. But I stumbled upon Joda
Api, hence I was curious to know if Joda is capable of doing this
without a time zone conversion. Example:

clientDateTime.isBeforeNow()
  • 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-16T04:04:37+00:00Added an answer on June 16, 2026 at 4:04 am

    Yes, Joda DateTime comparisons with current time do not require a time zone conversion.

    When comparing with current time, such as DateTime.isBeforeNow and DateTime.isAfterNow, Joda simply compares the underlying absolute milliseconds since Jan 1, 1970. The same instant in time has exactly the same absolute milliseconds value, regardless of the timezone.

    For example, the instant 1355625068295 corresponds to:

    DateTime dt = new DateTime(1355625068295L);
    
    DateTime utc = dt.withZone(DateTimeZone.UTC);
    DateTime ny = dt.withZone(DateTimeZone.forID("America/New_York"));
    DateTime tk = dt.withZone(DateTimeZone.forID("Asia/Tokyo"));
    
    System.out.println(utc.getMillis() + " is " + utc);
    System.out.println(ny.getMillis() + " is " + ny);
    System.out.println(tk.getMillis() + " is " + tk);
    

    Output:

    1355625068295 is 2012-12-16T02:31:08.295Z
    1355625068295 is 2012-12-15T21:31:08.295-05:00
    1355625068295 is 2012-12-16T11:31:08.295+09:00
    

    And when comparing with “now”:

    System.out.println("now: " + new DateTime().getMillis());
    System.out.println(ny.isBeforeNow());
    System.out.println(ny.plusHours(1).isAfterNow());
    System.out.println(tk.isBeforeNow());
    System.out.println(tk.plusHours(1).isAfterNow());
    

    Output:

    now: 1355625752323
    true
    true
    true
    true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to check to see if a given email say for example (yourname@your_domain.com)
I want to check whether a given file exists in android sd card. I
Okay I have the following problem. I want to get the current dateTime and
I want to check if a given URL exists and it's an image, in
I want to check if a given Class is assignable to a java.util.Collection, and
I want to check if a given string appears multiple times in some scenarios
Well given I have a value I want to check for potential matches in
For a given Element, I want to check whether the xsi:nil attribute is set
I want to check given node is exist or not in *.xml file. I
In C, I want to check a given array of chars for an arbitrary

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.