Extract time from Calendar Object

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jrhitokiri
    New Member
    • Apr 2008
    • 35

    Extract time from Calendar Object

    I just want to extract the time component of the calendar object for comparison to another. Is this possible?

    here's my code:
    Code:
    try {
        String str_date="2009-10-15 12:1:00";
        DateFormat formatter =
            new SimpleDateFormat("yyyy-MM-dd k:mm:ss");
        Date date = (Date)formatter.parse(str_date); 
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        System.out.println("Today is " +date );
    			
        //need to do something here to get just the time field
        //for comparing. Just the hours, minutes and seconds.
        //I want to do something like
        //if (cal.getTime() > someTimeObject )
        // do something here
    } catch (java.text.ParseException e) { e.printStackTrace(); }
    thanks!

    kind regards.
    JR
  • jrhitokiri
    New Member
    • Apr 2008
    • 35

    #2
    bumping this question.. anyone want to answer this? T_T

    Comment

    Working...