473,403 Members | 2,071 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,403 software developers and data experts.

How to calculate time in java

i have already used Simple Date Format method.i got the time from the system.that i am stored in sql.in sql i used datetime datatype.it gives date and time.but i need only time.and how to subtract the time.
Jul 25 '06 #1
5 19361
The method getTime( ) gives to you how many milisecs are since 1900 ( i think ), use it to make all operations you need.
Aug 1 '06 #2
hi ,
Thank u for ur reply.Do u know how to increase the column width in JTable.
Aug 9 '06 #3
1. declare a long type variable --> long lng;
2. assign it to time --> lng=System.currentTimeMillis();
--> System.out.println(lng);


import java.util.*;

class time
{
public static void main (String[] arg){
long lng;
lng=System.currentTimeMillis();
System.out.println(lng);
}
}

it'll print system time since 1980..........?????
Aug 2 '07 #4
JosAH
11,448 Expert 8TB
it'll print system time since 1980..........?????
That's why it's so comfortable to have all the API documents available locally:

Returns the current time in milliseconds. Note that while the unit of time of the
return value is a millisecond, the granularity of the value depends on the
underlying operating system and may be larger. For example, many operating
systems measure time in units of tens of milliseconds.
See the description of the class Date for a discussion of slight discrepancies
that may arise between "computer time" and coordinated universal time (UTC).

Returns:
the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
kind regards,

Jos
Aug 2 '07 #5
blazedaces
284 100+
hi ,
Thank u for ur reply.Do u know how to increase the column width in JTable.
Ok, what you're going to want to do is use JTable's getColumnModel() method and then afterwards use the TableColumnModel's getColumn(index) method. Then just set the preferred/max/min widths. Check out the following documentation on both of them:

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTable.html

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumnModel.html

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/table/TableColumn.html

I've done this before so though I know it's not the easiest concept, try it for yourself and tell me if you get stuck on a problem.

Good luck,
-blazed
Aug 2 '07 #6

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

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
7
by: Tim Quon | last post by:
Hi Is there any function to get the current time so I can calculate the execution time of my code? What all is in the time.h and sys/times.h? Thanks Tim
13
by: Martin Herbert Dietze | last post by:
Hi, I need to calculate the physical length of text in a text input. The term "physical" means in this context, that I consider 7bit-Ascii as one-byte-per character. Other characters may be...
6
by: rohayre | last post by:
Im a long time java developer and actually have never done anything with java scripting. I'd like to write a short simple script for calculating a date in the future based on today's date and a...
2
by: foleyflint | last post by:
Hello, I'm trying to calculate the interest from a bankaccount which is displayed in a text file as followed: 9 2 345 3 3 300 etc. (there are 19 lines in total) the first number...
5
by: leelaramtenneti | last post by:
How to find Hyperbolic cosine of a complex number ???? i.e cosh(a+jb)= ???
2
ruch095
by: ruch095 | last post by:
i'm student and my project work about RTP Protocol (Develop with java),now i want a algorithm for calculate NTP timestamp(header of rtcp protocol).Anybody who have this algorithm,please tell me. ...
3
by: lizBeth | last post by:
Hi all, i seem to have gotten stuck on this coursework, i am unsure as to how to implement a method in the main class to calculate the sum of all employees monthly salaries. Everything...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.