Help With Dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vrkamalakar
    New Member
    • Jan 2007
    • 16

    #1

    Help With Dates

    Hi,

    I got a scenario where the user gets an id which will expire in 24 hours. Now for that validation I need to update a field ie., set expiration time for 24 hours from the current time.

    When the user logs in with that userid I need to check whether the id has expired or still valid. How do I set the time. Can I get some code please.

    I got two functions which converts string to date and date to string

    private String dateToStringCon version(Date date) {
    String ldapDate = null;
    SimpleDateForma t ldapFormat =
    new SimpleDateForma t("yyyyMMdd") ;
    ldapDate = ldapFormat.form at(date);
    return ldapDate;
    }


    private Date stringToDateCon version(String value) {
    Date date = null;
    SimpleDateForma t ldapFormat =
    new SimpleDateForma t("yyyyMMdd") ;
    date = ldapFormat.pars e(value);
    return date;
    }


    But how to set time ie., validate a field for 24 hours.......Ple ase give me some code....

    Regards
    Kamal
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by vrkamalakar
    Hi,

    I got a scenario where the user gets an id which will expire in 24 hours. Now for that validation I need to update a field ie., set expiration time for 24 hours from the current time.

    When the user logs in with that userid I need to check whether the id has expired or still valid. How do I set the time. Can I get some code please.

    I got two functions which converts string to date and date to string

    private String dateToStringCon version(Date date) {
    String ldapDate = null;
    SimpleDateForma t ldapFormat =
    new SimpleDateForma t("yyyyMMdd") ;
    ldapDate = ldapFormat.form at(date);
    return ldapDate;
    }


    private Date stringToDateCon version(String value) {
    Date date = null;
    SimpleDateForma t ldapFormat =
    new SimpleDateForma t("yyyyMMdd") ;
    date = ldapFormat.pars e(value);
    return date;
    }


    But how to set time ie., validate a field for 24 hours.......Ple ase give me some code....

    Regards
    Kamal
    Have a look at java.util.Grego rianCalendar.

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      1)the simple way is to read a file every time the program is executed.
      The file will have a count in an encripted way.when count reaches a certain number stop executing.
      Every time the program runs you should update the file.


      2)you can hardcode a date in your program and every time the program runs,compare the date with system date.
      3)as r0 said u can use Gregorian calender

      best of luck
      Originally posted by r035198x
      Have a look at java.util.Grego rianCalendar.

      Comment

      Working...