Butch Smith
asked on
Adobe PDF Professional calculate time difference
We created a form in PDF professional and have the user input two time fields as HH:MM:SS. We have another field that is to calculate the time difference between the two fields. We tried a simple field1 - field2. This works only if the format is not in time, but unfortunately it is.
Any ideas. The two fields that are to be calculated are (dispatchtime) and (onscenetime)
Thanks
Any ideas. The two fields that are to be calculated are (dispatchtime) and (onscenetime)
Thanks
Don't know how you could apply it to Adobe, but this is java snippet
which should giive you difference in time in seconds in case you need it
(hours are on 24 scale - 0-23):
String field1 = "10:15:00";
String field2 = "10:30:00";
SimpleDateFormat ff = new SimpleDateFormat("HH:mm:ss
java.util.Date d1 = ff.parse(field1, new ParsePosition(0));
java.util.Date d2 = ff.parse(field2, new ParsePosition(0));
long time_sec = (d2.getTime()-d1.getTime()
System.out.println("Time: " + time_sec);
ASKER
In java editor we get an error that highlights the String field2 = "10:30:00";
says: syntaxerror: missing ; before statement 1 : at line 2
says: syntaxerror: missing ; before statement 1 : at line 2
Well, don't know waht you mean by Java editor;
though this is a perfectly valid java statement,
this is all just a snippet - in java it would normally be part of the class, maybe that's
what your editor is complaining about - as it is lacking the context.
The context should depend on how you can attach it to your problem with PDF .
Maybe this is what your java editor can accept, but we really need to
know how to apply it to your Adobe form
though this is a perfectly valid java statement,
this is all just a snippet - in java it would normally be part of the class, maybe that's
what your editor is complaining about - as it is lacking the context.
The context should depend on how you can attach it to your problem with PDF .
Maybe this is what your java editor can accept, but we really need to
know how to apply it to your Adobe form
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
public class TimeDifference {
public static void main(String [] args){
String field1 = "10:15:00";
String field2 = "10:30:00";
SimpleDateFormat ff = new SimpleDateFormat("HH:mm:ss");
java.util.Date d1 = ff.parse(field1, new ParsePosition(0));
java.util.Date d2 = ff.parse(field2, new ParsePosition(0));
long time_sec = (d2.getTime()-d1.getTime())/1000L;
System.out.println("Time: " + time_sec);
}
}
ASKER
CEHJ
I see your link, but have a hard time understanding where to place my two time fields. My first time field is called "dispatchtime" and my second is called "onscenetime"
Thanks
I see your link, but have a hard time understanding where to place my two time fields. My first time field is called "dispatchtime" and my second is called "onscenetime"
Thanks
ASKER
YAN,
We still get an error.
We still get an error.
What are you using?
This my code compiles in java IDE without any problems.
Are you using javac to compile, if you are using IDE, then what IDE?
This my code compiles in java IDE without any problems.
Are you using javac to compile, if you are using IDE, then what IDE?
This was compiled - this is valid java.
Java compiler should noit write any errors - send me the deatlis
we should ceertainly understand this
ASKER
This is what adobe says about java script. Again this is creating a adobe acrobat professional form
Based on JavaScript version 1.5 of ISO-16262 (formerly known as ECMAScript), JavaScript in Adobe Acrobat software implements objects, methods, and properties that enable you to manipulate PDF files, produce database-driven PDF files, modify the appearance of PDF files, and much more. You can tie Acrobat JavaScript code to a specific PDF document, a page, field, or button within that document, or a field or button within the PDF file, and even to a user action.
Based on JavaScript version 1.5 of ISO-16262 (formerly known as ECMAScript), JavaScript in Adobe Acrobat software implements objects, methods, and properties that enable you to manipulate PDF files, produce database-driven PDF files, modify the appearance of PDF files, and much more. You can tie Acrobat JavaScript code to a specific PDF document, a page, field, or button within that document, or a field or button within the PDF file, and even to a user action.
JavaScript is ablsolutely different animal.
It is not Java programming language
It is not Java programming language
check here for javaScript time difference
http://forums.aspfree.com/html-javascript-and-css-help-7/calculate-difference-between-two-times-212351.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER