Results 1 to 2 of 2
  1. #1
    gita is offline Member
    Join Date
    Feb 2011
    Rep Power

    Default how to validate a long value is in valid UTC time format

    a long value is passed in by user (datetimestamp value)

    need to validate if it is in a valid UTC format in java

  2. #2
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    Every long value represents a valid date/time. But if you need to verify that it is within some range, then I suggest using a java.util.GregorianCalendar.

    Java Code:
    import java.util.*;
    Date date = new Date(longMsSinceUnixEpoch);
    GregorianCalendar cal = new GregorianCalendar();
    int year = cal.get(Calendar.YEAR);
    A java.util.Date can be constructed from a long (representing ms since the unix epoch - midnight Jan 1 1970)

Similar Threads

  1. Long wait time before print job reaches printer
    By Astghik in forum AWT / Swing
    Replies: 0
    Last Post: 01-12-2010, 11:29 AM
  2. Convert String to Time format
    By plasma in forum New To Java
    Replies: 1
    Last Post: 12-16-2009, 09:58 AM
  3. Validate DATE format in applet
    By only2008 in forum Java Applets
    Replies: 4
    Last Post: 09-29-2009, 09:20 AM
  4. validate time input format
    By Alairmon in forum New To Java
    Replies: 2
    Last Post: 11-04-2008, 08:39 AM
  5. It takes very long time.....
    By iresha in forum Advanced Java
    Replies: 6
    Last Post: 05-11-2008, 02:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts