Results 1 to 3 of 3
  1. #1
    gorgon777 is offline Member
    Join Date
    Jan 2014
    Posts
    15
    Rep Power
    0

    Default How to set time for Calender

    Hello,

    I would like to set a specific time for a Calendar instance. My below code will set a time one minute ahead of the current time, and format it to ISO8601 standard.

    Java Code:
    Calendar reminderDate = Calendar.getInstance();
    System.out.println(dateFormat.format(reminderDate.getTime()));
    reminderDate.add(Calendar.MINUTE,1);
    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    String finalReminderDate = sdf1.format(reminderDate.getTime());

    I now want to set another variable(deadlineDate), but to a specific time, say 5 minutes ahead. I would like to hardcode this in so I dont want it to change as a result of getting the instance of the Calendar(which sets it to the current time)

    Essentially I am trying to regenerate the above code every minute and increment itself each cycle until it reaches the deadlineDate, which is a fixed datetime.

    How can I do this?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default Re: How to set time for Calender

    See the API docs for Timer and TimerTask.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,873
    Rep Power
    25

    Default Re: How to set time for Calender

    Also look at the SimpleDateFormat class's parse() method.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. calender in jframe
    By pardhu in forum AWT / Swing
    Replies: 4
    Last Post: 11-08-2011, 11:59 PM
  2. Replies: 18
    Last Post: 05-11-2011, 08:36 AM
  3. calender
    By sameerRKO in forum Eclipse
    Replies: 0
    Last Post: 02-27-2011, 07:48 PM
  4. Calender
    By dewitrydan in forum New To Java
    Replies: 4
    Last Post: 10-20-2010, 08:36 PM
  5. Calender
    By tiger100plus in forum New To Java
    Replies: 1
    Last Post: 12-26-2008, 08:20 PM

Posting Permissions

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