473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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:
Expand|Select|Wrap|Line Numbers
  1. try {
  2.     String str_date="2009-10-15 12:1:00";
  3.     DateFormat formatter =
  4.         new SimpleDateFormat("yyyy-MM-dd k:mm:ss");
  5.     Date date = (Date)formatter.parse(str_date); 
  6.     Calendar cal = Calendar.getInstance();
  7.     cal.setTime(date);
  8.     System.out.println("Today is " +date );
  9.  
  10.     //need to do something here to get just the time field
  11.     //for comparing. Just the hours, minutes and seconds.
  12.     //I want to do something like
  13.     //if (cal.getTime() > someTimeObject )
  14.     // do something here
  15. } catch (java.text.ParseException e) { e.printStackTrace(); }   
  16.  
thanks!

kind regards.
JR
Oct 17 '09 #1
1 2993
bumping this question.. anyone want to answer this? T_T
Oct 17 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob | last post by:
Why is this not returning the right day or month? It gives me 5 when the rightnow variable gives a 18. import java.util.Calendar; public class Test { public static void main(String args) {...
1
by: Don | last post by:
I have a form that uses an Image object to open a report (the report is based on a query). I used the image object because the MS command buttons are dull looking. All of this works well. The...
10
by: KevinL | last post by:
I'm writing a random number generator program and using time() to seed it. I found out that time() output is in seconds. Do you know of another function that outputs in thousands of seconds ? ...
0
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
19
by: Melvin G. Sheppers | last post by:
I want to display the time in a particular timezone (US Central) regardless where the computer is located. I have written the script below which displays the time in the Eastern, Central, Mountain,...
1
by: dangier | last post by:
I have an Access 2003 table with an XML field that is tagged as follows: <Calendar CompactMode="1"><CustomProperties><CustomProperty Name="startdate" Value="3/26/2007"...
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
3
by: panos100m | last post by:
Relevant part of the code:: //that code wouldnt work ..its purpose is to compare the current time with a give time (in this case italian) //output of current time is displayed as 0001 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.