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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:47:26+00:00 2026-05-23T20:47:26+00:00

I need validate the given input String is a valid Timestamp in milliseconds. For

  • 0

I need validate the given input String is a valid Timestamp in milliseconds.

For example if the given Timestamp

String time ="1310966356458";

Then it should return true.

if

String time ="1000";

then it should return false;

Please help. Thanks in advance

  • 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-23T20:47:28+00:00Added an answer on May 23, 2026 at 8:47 pm

    We cannot tell you what is sensible for your application. If there was a limit which was correct for every situation it would be built in. It could be that only timestamps after you developed your application and not in the future are sensible.

    public static final String RELEASE_DATE = "2011/06/17";
    private static final long MIN_TIMESTAMP;
    
    static {
        try {
            MIN_TIMESTAMP = new SimpleDateFormat("yyyy/MM/dd").parse(RELEASE_DATE).getTime();
        } catch (ParseException e) {
            throw new AssertionError(e);
        }
    }
    
    // after the software was release and not in the future.
    public static final boolean validTimestamp(long ts) {
        return ts >= MIN_TIMESTAMP && ts <= System.currentTimeMillis();
    }
    

    However, it could be that the timestamp represents when someone was born. In which case the minimum timestamp could be negative.

    It could be that the timestamp is the time when something expires (like tickets) Some will be in the past (perhaps not before this year) and some will be in the future. (perhaps not more than 2 years in advance.)


    Times can be negative. Man landed on the moon before 1970 so the timestamp would be negative.

    String MAN_ON_MOON = "1969/07/21 02:56 GMT";
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm Z");
    System.out.println(sdf.parse(MAN_ON_MOON).getTime());
    

    prints

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

Sidebar

Related Questions

I need the absoulute fastest way possible to validate an input string against a
I need to validate a date/time field on a webpage but want it to
I need to validate an XML string (and not a file) against a DTD
I need to validate the user input of a JSpinner , and if invalid,
For example, if I have a user model and I need to validate login
I read that you do not need to validate or sanitize user's input if
I need to validate a user input of about 1,500 characters Allowed characters are
I need to validate a given Name field in the asp.net form. User Name:
I have two Dictionary<string, byte> properties in my model that should validate properly with
I need to validate a column having time ranges like '8:00 am - 9:00

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.