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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:37:00+00:00 2026-05-26T12:37:00+00:00

JodaTime has public final class DateTime extends BaseDateTime {…} which works its way up

  • 0

JodaTime has

public final class DateTime extends BaseDateTime {...}

which works its way up to

public interface ReadableInstant extends Comparable<ReadableInstant>

Hamcrest has

public static <T extends java.lang.Comparable<T>> org.hamcrest.Matcher<? super T>
    greaterThan(T value) {...}

If I try

greaterThan(new DateTime());

then I get a compile error (Eclipse gives most clue)

The generic method greaterThan(T) of type Matchers is not applicable
for the arguments (DateTime). The inferred type DateTime is not a valid substitute
for the bounded parameter >

Am I right in thinking that the signature of greaterThan should actually be

public static <T extends java.lang.Comparable<? super T>> org.hamcrest.Matcher<? super T>     
    greaterThan(T value)

? And is there a way to fit these together short of casting to the raw Comparable?

  • 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-26T12:37:01+00:00Added an answer on May 26, 2026 at 12:37 pm

    Yes, it looks to me like that would be a better signature.

    Have you tried specifying the comparison type explicitly?

    Matchers.<ReadableInstant>greaterThan(new DateTime());
    

    I don’t believe you can call it using a static import and also specifying the type argument, unfortunately – but that may not be too much of hardship.

    Of course an alternative is to cast the argument:

    greaterThan((ReadableInstant) new DateTime());
    

    I don’t have Hamcrest handy, but the above worked fine for me using the signature you’d given me, in a test type.

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

Sidebar

Related Questions

Which is the most beneficial in Java and a DB for DateTime? (Using JodaTime
I have a model called Booking which has a persistent DateTime field. However I
I have a JodaTime Period that I've created from two DateTime instants. Is there
I use jodatime to parse date time strings as follows: public static void main(String[]args){
Is there a API method in JodaTime to see whether a DateTime is within
What is the simplest way to convert a JodaTime LocalDate to java.util.Date object?
My Domain object has couple of Joda-Time DateTime fields. When I'm reading database values
The situation is something like this: PostgreSQL Database table has a field dateAdded which
Am using DateTime from Jodatime to know , the current date is greater or
I got a custom class that contains JodaTime's LocalDate variable to hold a 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.