Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11342

Re: How can I use Operand (+ , - ) with Time

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: How can I use Operand (+ , - ) with Time
Date Sun, 15 Jan 2012 10:19:59 -0500
Organization A noiseless patient Spider
Lines 88
Message-ID <jeuqcs$32i$1@dont-email.me> (permalink)
References <34afdd1f-4549-48a9-878c-8678993e97ed@t30g2000vbx.googlegroups.com> <jeuk41$pq$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sun, 15 Jan 2012 15:12:28 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="qwFw1g9RsQ6TkML5yezG9A"; logging-data="3154"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hUYltITbs9lEDtc7b4d7kUJXcsyhOcgo="
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11
In-Reply-To <jeuk41$pq$1@dont-email.me>
Cancel-Lock sha1:rs3xkeIzriHfzTJLaO9DsQjgfwg=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11342

Show key headers only | View raw


On 01/15/2012 08:32 AM, Jeff Higgins wrote:
> On 01/15/2012 02:44 AM, sahm wrote:
>> Hi every One
>>
>> I'm Try to do program to calculate the Over Time, I'm working with 24
>> hour not A.M.& P.M. and this is my Time format (HH:MM:SS) (00:00:00).
>> But how can I use operand (+, -) with Time
>
> See Stefan for the answer.
> An alternative follows.
>
>> This is my Code
>>
>> /////////////////////////////////////////////////////////////////////
>> import java.sql.Time;
>> import java.util.Date;
>>
>>
>> public class OverTimeDetailsDataClass {
>>
>> String Emp_ID;
>> String OverTime_Doc_NO;
>> String OverTime_Date;
>> Time OverTime_Start_Time;
>> Time OverTime_End_Time;
>> Time OverTimeTotalHours;
>>
>> OverTime_Start_Time =
>> Time.valueOf(OverTimeFromjTextField.getText());
>> OverTime_End_Time = Time.valueOf(OverTimeTOjTextField.getText());
>> OverTimeTotalHours = OverTime_End_Time - OverTime_Start_Time;
>> }
>
> import java.sql.Time;
> import java.util.Calendar;
> import java.util.Locale;
> import java.util.TimeZone;
>
> import javax.swing.JTextField;
>
>
> public class OT {
>
> public static void main(String[] args) {
>
> JTextField OverTimeFromjTextField = null;
> JTextField OverTimeTOjTextField = null;

   // The abstract class java.text.DateFormat
   // and it's concrete java.text.SimpleDateFormat
   // are good for getting/setting formatted input/output

>
> Time OverTime_Start_Time;
> Time OverTime_End_Time;

   // Unless you are using the JDBC API
   // you should avoid using the java.sql classes:
   // java.sql.Date, java.sql.Time, java.sql.Timestamp

   // in favor of java.util.Date, java.util.Calendar,
   // java.util.GregorianCalendar, java.util.Locale,
   // java.util.TimeZone, java.util.SimpleTimeZone

>
> // Be aware: read the documentation for java.util.Calendar
> TimeZone timeZone = TimeZone.getDefault();
> Locale locale = Locale.getDefault();
>
> Calendar startTime = Calendar.getInstance(timeZone,locale);
> Calendar endTime = Calendar.getInstance(timeZone,locale);
>
> OverTime_Start_Time =
> Time.valueOf(OverTimeFromjTextField.getText());
> OverTime_End_Time = Time.valueOf(OverTimeTOjTextField.getText());
>
> startTime.setTime(OverTime_Start_Time);
> endTime.setTime(OverTime_End_Time);
>
> // use the java.util.Calendar.add(int field, int amount) method
> // as described in the documentation.
>
> }
>
> }
>
>

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How can I use Operand (+ , - )  with Time sahm <sahm007@gmail.com> - 2012-01-14 23:44 -0800
  Re: How can I use Operand (+ , - )  with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 08:32 -0500
    Re: How can I use Operand (+ , - )  with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 08:52 -0500
    Re: How can I use Operand (+ , - )  with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 10:19 -0500
      Re: How can I use Operand (+ , - ) with Time sahm <sahm007@gmail.com> - 2012-01-15 07:55 -0800
        Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:50 -0800
  Re: How can I use Operand (+ , - )  with Time Roedy Green <see_website@mindprod.com.invalid> - 2012-01-15 08:35 -0800
  Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:31 -0800
    Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 10:51 -0800
    Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 14:45 -0500
      Re: How can I use Operand (+ , - ) with Time Jeff Higgins <jeff@invalid.invalid> - 2012-01-15 15:53 -0500
      Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 15:36 -0800
    Re: How can I use Operand (+ , - ) with Time glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-15 20:07 +0000
      Re: How can I use Operand (+ , - ) with Time Lew <noone@lewscanon.com> - 2012-01-15 15:39 -0800

csiph-web