Java Time Counter / Date Class Question

I am trying to make a program that if a input is recieved it will record the time and when another input is recieved it will record the time as well.
I am sorry of stupid question:
1. how do i minus both "timing"? i try to directly minus it, but doesn't seem to work .
2. in the java Doc it say it can only take up to milli seconds. Is this the smallest time unit i could mesaure?

I am trying to make a program that if a input is
recieved it will record the time and when another
input is recieved it will record the time as well.
I am sorry of stupid question:
1. how do i minus both "timing"? i try to directly
minus it, but doesn't seem to work .
2. in the java Doc it say it can only take up to milli
seconds. Is this the smallest time unit i could
mesaure?1.
long start = System.currentTimeMillis();
// do something
long end = System.currentTimeMillis();
long elapsed = end - start; //ms
2.
No there are smaller.
Java Tiger (1.5) offers a nano unit for measuring issues.
currentTimeMillis()
Returns the current time in milliseconds.
nanoTime()
Returns the current value of the most precise available system timer, in nanoseconds.
good luck!

Similar Messages

  • Java time counter ?

    Hi,
    Is there anyway to set time counter on java?
    My friend suggested that I can use util.date at the begining of my program and use it again at the end, after compare these two value, I can get the time period of the program.
    However, since util.date will read the time from OS, if user set the OS clock back or forward, I cannot get accurate time.
    My program is really sensitive with time (I have to get exactly time the user uses my program.)
    Can anyone please have any suggestion about it?
    Thank you

    > The external class Clock from the javabook package can assist you in your quest.
    The internal class Timer from the java.util (or javax.swing) package can assist with his quest and doesn't require external libraries. If the user is interested in external libraries, I'd recommend the Commons Lang StopWatch* class, which is part of the Commons Lang library, which contains a wealth of useful classes.
    * http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/time/StopWatch.html
    ~

  • Java.sql.Date and java.util.Date - class loaded first in the classpath

    I had two jar files which has java.util.Date and java.sql.Date class file. i want to know whether which class is loaded first in the classpath...
    I like to change the order of loading the class at runtime...
    Is there is any way to change the order of loading of class...
    I may have different version of jar files for example xerces,xercesImpl. some of the code uses xerces ,some of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according to the order i need..
    Can we do all these in Run time ?????

    I had two jar files which has java.util.Date and
    java.sql.Date class file. i want to know whether
    which class is loaded first in the classpath...
    I like to change the order of loading the class at
    runtime...
    Is there is any way to change the order of loading of
    class...
    I may have different version of jar files for example
    xerces,xercesImpl. some of the code uses xerces ,some
    of the code uses xercesImpl..i had common classes.
    I like to load the class with the same name according
    to the order i need..
    Can we do all these in Run time ?????That is meaningless.
    The classes you are referring to are part of the Java API. Third party jars have no impact on that. And you can't change to the order because java.sql.Data is derived from java.util.Date. So the second must load before the first.
    And if you have two jar files with those classes in them (and not classes that use them) then you either should already know how to use them or you should stop trying to do whatever you are doing because it isn't going to work.

  • Get days from the java.util.date class

    Does anyone know how to get the days from the java.util.date
    class. I'm trying to subtract two dates to get the total days between
    the two dates. Any help would be appriciated
    Rob

    If you use the getTime() method, you get the date as a number of milliseconds since a predefined time. You can do arithmetic on that number, such as subtracting two of them to get the number of milliseconds between two Dates, and so on.

  • Java.io.IOException: Resource not found: org/joda/time/tz/data/ZoneInfoMap

    I've been attempting to develop test classes using the PowerMock and Mockito mock frameworks
    I've developed the tests in Eclipse in windows XP (64 bit) and the tests run to completion with passes
    One of the classes being tested references the joda-time-1.4.jar and this jar contains the resource org/joda/time/tz/data/ZoneInfoMap
    I then attempted to migrate the development to running the unit tests in a Windows XP command prompt launched by Maven 2 (mvn)
    I get test errors, but the nature of the error depends where I set my JAVA_HOME
    a) if I set my JAVA_HOME to a standard Sun JDK (C:\Program Files (x86)\Java\jdk1.5.0_21), then I get the resource not found error for one test only - here is an extract from the exception:
    Running com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest
    Exception in thread "main" java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: org.powermock.core.classloader.MockClassLoader@3ab28980
    at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:206)
    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:123)
    at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:82)
    at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:435)
    at org.joda.time.DateTimeZone.setProvider0(DateTimeZone.java:389)
    at org.joda.time.DateTimeZone.<clinit>(DateTimeZone.java:113)
    at org.joda.time.chrono.GregorianChronology.<clinit>(GregorianChronology.java:71)
    at org.joda.time.chrono.ISOChronology.<clinit>(ISOChronology.java:66)
    at org.joda.time.base.BaseDateTime.<init>(BaseDateTime.java:97)
    at org.joda.time.DateTime.<init>(DateTime.java:114)
    at com.visaeu.rcs.cts.datetime.RCSDateTime.<init>(RCSDateTime.java:178)
    at com.visaeu.rcs.cts.datetime.RCSDateTime.<clinit>(RCSDateTime.java:53)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8Helper.setTcr8ValuesInTransaction(RCSInternalTCR8Helper.java:230)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8Helper.bindTcr8(RCSInternalTCR8Helper.java:164)
    at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest.testBindSampleData(RCSInternalTCR8HelperTest.java:423)
    b) if I set my JAVA_HOME to an IBM JDK (C:\Program Files (x86)\IBM\SDP70\jdk), then I get NoClassDefFoundError for any test that attempts to create a mock - here is an extract from the exception:
    testBindSampleData(com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest) Time elapsed: 0 sec <<< ERROR!
    java.lang.NoClassDefFoundError: com.visaeu.rcs.cts.codepagetranslation.RCSCodepageTranslationService$$EnhancerByMockitoWithCGLIB$$c7baa0a
         at sun.reflect.GeneratedSerializationConstructorAccessor12.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
         at org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator.newInstance(SunReflectionFactoryInstantiator.java:40)
         at org.objenesis.ObjenesisBase.newInstance(ObjenesisBase.java:59)
         at org.mockito.internal.creation.jmock.ClassImposterizer.createProxy(ClassImposterizer.java:120)
         at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:60)
         at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:79)
         at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:53)
         at org.powermock.api.mockito.PowerMockito.mockStatic(PowerMockito.java:67)
         at com.visaeu.rcs.application.cas.parser.RCSInternalTCR8HelperTest.testBindSampleData(RCSInternalTCR8HelperTest.java:391)
    Finally, running the tests on a unix host under the AIX OS launched with Maven 2 (mvn), I get the Resource not found: "org/joda/time/tz/data/ZoneInfoMap" error
    None of these errors occur when running the tests in Eclipse, so there must be a different environment
    I've not been able to track it down, so if anyone can throw any light or offer a solution, that would be much appreciated
    Thanks for reading and any help

    Reposting with modified query under Core APIs - Reflections & Reference Objects
    I think this may be a more relevant forum

  • Mobile Device - Setting System Time/Date class

    Hi All,
    If I use the java.util.Date class, it returns a different time on the .toString() method than my clock is actually showing... The .toString() returns a time that is 2 hour behind.
    Basically, my timezone is GMT+2. So, if my time (displayed on my clock top right corner of my device's screen) is 3:00, the .toString() method returns that it is actually 1:00!
    Why could it be 2 hours behind??? Where does the Date class actually get the time from?
    tks
    Christiaan

    You can also use WMI to set the time on remote computers.
    (From the Windows PowerShell 2.0 Bible)
    $Credential = Get-Credential
    foreach ($Server in Get-Content -Path c:\Scripts\Servers.txt)
    $TimeObject = @{
    Class = "Win32_OperatingSystem"
    ComputerName = $Server
    Credential = $Credential
    EnableAllPrivileges = $true
    $CurrentTime = ([wmi]'').ConvertFromDateTime($(Get-Date))
    (Get-WmiObject @TimeObject).SetDateTime($CurrentTime)
    Karl
    My Blog: http://unlockpowershell.wordpress.com
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})

  • HT1386 When I try to sync my ipod it comes up with a message saying "iTunes was unable to load data class information from Sync Services. Reconnect or try again later". I have reconnected and tried later numerous times! Has anyone else had this problem?

    When I try to sync my iPod touch it comes up with a message saying "iTunes was unable to load data class information from Sync Services. Reconnect or try again later". I have reconnected and tried again later numerous times and it hasn't worked! Has anybody else had this problem and knows how to fix it??? Help me!

    Try here:
    iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert
    If not successful see the previous discussion on the right side of this page with the green checkmark.

  • How To Add Days into a Date from java.util.Date class

    I have a problem when i wants to add 2 or days into a
    date object geting by java.util.Date class. so please help me resolve this issue?
    for e.g i have a date object having 30/06/2001,
    by adding 2 days i want 02/07/2001 date object ?
    Code
    public class test2
    public static void main(String args[])
    java.util.Date postDate = new java.util.Date();
    myNewDate = postDate /* ?*/;
    Here i want to add 2 date into postDate

    Use Calendar...
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(Calendar.DAY, 2); // I'm not sure about that "DAY"

  • Simple java date related question

    Hi Friends,
    I have written this custom date class that compares two dates. The user can enter any number of days,and it should calculate the next date,is that possible???
    public class Date implements Comparable {
         private int month, day, year;
         public Date(int m, int d, int y) {
              month = m;
              day = d;
              year = y;
         public int compareTo(Object o) {
              Date a = this;
              Date b = (Date) o;
              if (a.year < b.year) return -1;
              if (a.year > b.year) return 1;
              if (a.month < b.month) return -1;
              if (a.month > b.month) return 1;
              if (a.day < b.day) return -1;
              if (a.day > b.day) return 1;
              return 0;
         public String toString() {
              return month + "/" + day + "/" + year;
         public static void main(String[] args) {
              Date d1 = new Date(21, 03, 2007);
              int days = Integer.parseInt(args[0]);
              System.out.println("New date is:"); // Need to print new date
    Expected output:
    java Date 30
    New date is: 04/20/2007If this is not possible with this class,how can we do this, any ideas.
    Your help would be appreciated.
    Thanks

    Hi,
    Try this code out:
    import java.text.DateFormat;
    import java.util.*;
    import javax.swing.JOptionPane;
    public class SimpleDate {
         private int month, day, year;
         public SimpleDate() {
              Date date = new Date();
             String myString = DateFormat.getDateInstance().format(date);
             StringTokenizer tokens = new StringTokenizer(myString, "/");
             day = Integer.parseInt(tokens.nextToken());
             month = Integer.parseInt(tokens.nextToken());
             year = Integer.parseInt(tokens.nextToken());
         public SimpleDate(String stdate) {
              try {
                   StringTokenizer tokens = new StringTokenizer(stdate, "/");
                   day = Integer.parseInt(tokens.nextToken());
                   month = Integer.parseInt(tokens.nextToken());
                   year = Integer.parseInt(tokens.nextToken());
              catch(Exception e) {
                   Date date = new Date();
                  String myString = DateFormat.getDateInstance().format(date);
                  StringTokenizer tokens = new StringTokenizer(myString, "/");
                  day = Integer.parseInt(tokens.nextToken());
                  month = Integer.parseInt(tokens.nextToken());
                  year = Integer.parseInt(tokens.nextToken());
                   JOptionPane.showMessageDialog(null, "Invalid String,\nDate set to current", "Invalid String", JOptionPane.ERROR_MESSAGE);
         public SimpleDate(int d, int m, int y) {
              month = m;
              day = d;
              year = y;
         public int compareTo(Object o) {
              SimpleDate a = this;
              SimpleDate b = (SimpleDate) o;
              if (a.year < b.year) return -1;
              if (a.year > b.year) return 1;
              if (a.month < b.month) return -1;
              if (a.month > b.month) return 1;
              if (a.day < b.day) return -1;
              if (a.day > b.day) return 1;
              return 0;
         private int getNumOfDaysInMonth() {
              boolean leap = false;
              int days = 30;
              if (year % 4 == 0) leap = true;
              if ((month == 1) | (month == 3) | (month == 5) | (month == 7) |
                        (month == 8) | (month == 10) | (month == 12)) {
                   days = 31;
              if ((month == 4) | (month == 6) | (month == 9) | (month == 11)) {
                   days = 30;
              if (month == 2) {
                   if (leap) {
                        days = 29;
                   else days = 28;
              return days;
         public void addDays(int nums) {
              while (nums > getNumOfDaysInMonth()) {
                   nums = nums - getNumOfDaysInMonth();
                   addMonths(1);
              day = day + nums;
              while (day > getNumOfDaysInMonth()) {
                   day = day - getNumOfDaysInMonth();
                   addMonths(1);
         public void addMonths(int nums) {
              while (nums > 12) {
                   nums = nums - 12;
                   addYears(1);
              month = month + nums;
              while (month > 12) {
                   month = month - 12;
                   addYears(1);
         public void addYears(int nums) {
              year = year + 1;
         public int getDay() {
              return day;
         public int getMonth() {
              return month;
         public int getYear() {
              return year;
         public String toString() {
              return day + "/" + month + "/" + year;
    }I have swapped the day and month around from mm/dd/yyyy to dd/mm/yyyy
    but otherwise its still the same basic code

  • I keep getting the following message every time i plug in my Iphone to Itunes on my windows vista computer  Itunes was unable to load data class information from sync services. reconnect or try again later.  any suggestions pls  Mario

    I keep getting the following message every time i plug in my Iphone3gs to Itunes on my windows vista computer
    Itunes was unable to load data class information from sync services. reconnect or try again later.
    any suggestions pls
    Mario

    The article says that I should upgrade to the latest iTunes. I am on the latest iTunes version.
    If you could read just a tiny little bit further, under the "Additional Information" section immediately after that, it says:
    If you are still experiencing this issue when syncing, or have not installed Xcode 4 and get this alert:
    Follow the troubleshooting steps in Mac OS X v10.5, v10.6: Resetting the SyncServices folder.
    If the issue is still unresolved, follow steps in Sync Services: Advanced troubleshooting for contact and calendar syncing.
    Have you tried those measures?

  • Using java.time.LocalDate class

    Hello,
    I am using the latest JDK8 build b87 and JDeveloper 11.1.2.1. In the editor, the code insight does not show the java.time.LocalDate class. When I use the LocalDate class, it is highlighted in red. However, I can compile and run the application fine. Other classes in the java.time package, for example, the Clock class is fine. I can use classes from the java.time subpackages fine. How can I fix this issue?
    Thanks
    Kishori

    JDeveloper does not support JDK 8 as indicated by the certification matrix.
    http://www.oracle.com/technetwork/developer-tools/jdev/index-091111.html
    java.time.LocalDate being a new class, code insight does not support the class.

  • HT1386 my ipad won't sink; I continually get message:  itunes was unable to load data class information from Sync Services. Reconnect or try again later.  I have done both several times and still receive same messaage.

    My iPad won't sink with my computer.  I continually receive this message: "iTunes was unable to load data class information from Sync Services.  Reconnect or try again later."  I have tried this over a number of days and receive the same message.  Any suggestions??

    IOS: Syncing with iTunes
    http://support.apple.com/kb/HT1386
    Apple - Support - iPad - Syncing
    http://www.apple.com/support/ipad/syncing/
    ITunes: Syncing media content to your iOS devices
    http://support.apple.com/kb/ht1351
    There are some similar posts on the right side of this page (More Like This). Look at those posts.
     Cheers, Tom

  • Query Question - Linking in Time Span Data to Point-in-Time References

    I am trying to pull historical data from a time-span table of records, using another point-in-time reference. I have been unsuccessful.
    I've thrown some sample tables and data together to illustrate what I am seeking:
    Create Table EmployeeInfo (
           id Number(10,0),               -- Employee ID Number
           Name VarChar2(32 Byte),        -- Employee Name
           CurrentShift VarChar2(2 Byte)  -- Current Employee Shift
    Create Table ShiftChanges (
           id Number(10,0),               -- Employee ID that this shift change record is for
           ChangeDate Date,               -- Date that this Change Took Place
           OldShift VarChar2(2 Byte),
           NewShift VarChar2(2 Byte)
    Create Table TimeCard(
           id Number(10,0),               -- Employee ID Number for this Timecard
           WorkDay Date,                  -- What Day is this Timecard for?
           Hours Float(63)                -- Number of Hours worked.
    COMMIT;
    INSERT INTO EmployeeInfo VALUES (100,'John Doe','Days')
    INSERT INTO EmployeeInfo VALUES (101,'Jane Doe','Days');
    INSERT INTO TimeCard VALUES (100, to_date('01012010','ddmmyyyy'), 10.5);
    INSERT INTO TimeCard VALUES (101, to_date('01012010','ddmmyyyy'), 10);
    INSERT INTO TimeCard VALUES (100, to_date('02012010','ddmmyyyy'), 9);
    INSERT INTO TimeCard VALUES (101, to_date('02012010','ddmmyyyy'), 10.5);
    INSERT INTO TimeCard VALUES (100, to_date('03012010','ddmmyyyy'), 8);
    INSERT INTO TimeCard VALUES (101, to_date('03012010','ddmmyyyy'), 7);
    INSERT INTO ShiftChanges VALUES (100, to_date('02012010','ddmmyyyy'), 'Nights', 'Days');
    COMMIT;I could do a query such as:
    SELECT TC.id,
           EM.Name,
           TC.Workday,
           EM.CurrentShift AS Shift
    FROM   TimeCard TC,
           EmployeeInfo EM
    WHERE  (TC.ID=EM.ID(+));But it will not give me the historical shift, only the current. Since John Doe changed shifts on Jan 2 from Nights to Days, the above query would not reflect it.
    I have attempted to join the historical table using a less-than operator. This doesn't work since more than one row can be returned.
    SELECT TC.id,
           EM.Name,
           TC.Workday,
           SC.NewShift AS Shift
    FROM   TimeCard TC,
           EmployeeInfo EM,
           ShiftChanges SC
    WHERE  (TC.ID=EM.ID(+)) AND
           (TC.ID=SC.ID(+) AND TC.WORKDAY<=SC.WORKDAY(+));The problem stems from the fact that you need to examine multiple records in one table in order to obtain the correct historical data for the other.
    The following SQL script {color:green}does work{color} - if the values are defined ahead of time.
    DEFINE EMPID=101;
    DEFINE CHGDATE=to_date('01/01/2010','dd/mm/yyyy');
    SELECT SQ.Shift
    FROM   (SELECT  ShiftChanges.NewShift AS Shift,
                    RANK() OVER (ORDER BY ShiftChanges.ChangeDate DESC) R
            FROM    ShiftChanges
            WHERE   ShiftChanges.id = &EMPID AND
                    ShiftChanges.ChangeDate <= &CHGDATE
            ) SQ
    WHERE R = 1However, I have been unsuccessful in adapting it to the example tables I provided. If I insert the query as an inline subquery* in the select statement, it won't work, since the criteria is nested two levels down, and I can only get parent values within the first level.
    I haven't thought of a way I can do this using a nested subquery - I keep running into that problem - how do you link in Time-Span data with a point-in-time reference.
    Any ideas / enlightening thoughts?
    Thank You
    {size:8}_SELECT * FROM V$VERSION information:_
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - Production
    PL/SQL Release 9.2.0.8.0 - Production
    "CORE     9.2.0.8.0     Production"
    TNS for 32-bit Windows: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    {size}
    user10879184 re-wrote the original post on 29-Mar-2010 1:21 PM to reflect suggestions made by poster.

    I changed the tables to hold VARCHAR2(6) shift information and your query to reference the ChangeDate column.
    I also assume you meant to link a TimeCard entry with the most previous ShiftChange entry rather than one that occurs after the time worked (TC.WORKDAY>=SC.CHANGEDATE(+) rather than TC.WORKDAY<=SC.CHANGEDATE(+)):
    Another issue you don't take into account the case where there has been no shift change. In that event you need the current shift from the EmployeeInfo table which is taken care of with the NVL function.
    You correctly note that multiple shift change records will result in duplicate TimeCard records though your test data fails to check for that condition. I added this row:
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('03012010','ddmmyyyy'), 'Days', 'Nights'); Now it is apparent
    SQL> SELECT TC.id,
      2         EM.Name,
      3         TC.Workday,
      4         NVL(SC.NewShift,EM.CurrentShift) AS Shift
      5  FROM   TimeCard TC,
      6         EmployeeInfo EM,
      7         ShiftChanges SC
      8  WHERE  TC.ID=EM.ID(+) AND
      9         TC.ID=SC.ID(+) AND TC.WORKDAY>=SC.CHANGEDATE(+);
            ID NAME                             WORKDAY   SHIFT
           100 John Doe                         01-JAN-10 Days
           100 John Doe                         02-JAN-10 Days
           100 John Doe                         03-JAN-10 Days
           100 John Doe                         03-JAN-10 Nights
           101 Jane Doe                         01-JAN-10 Days
           101 Jane Doe                         02-JAN-10 Days
           101 Jane Doe                         03-JAN-10 Days
    7 rows selected.The reason for the duplicate Jan3 time is the two shift change records. We are matching both ShiftChange records that occured before the 3rd.
    We also see that your test data has John starting out on Days and then shifting from Nights to Days on the 2nd for no real change. Fixing that:
    SQL> DELETE from ShiftChanges where ID = 100;
    2 rows deleted.
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('02012010','ddmmyyyy'), 'Days', 'Nights');
    1 row created.
    SQL> INSERT INTO ShiftChanges VALUES (100, to_date('03012010','ddmmyyyy'), 'Nights', 'Days');
    1 row created.Then:
    SQL> SELECT TC.id,
      2         EM.Name,
      3         TC.Workday,
      4         NVL(SC.NewShift,EM.CurrentShift) AS Shift
      5  FROM   TimeCard TC,
      6         EmployeeInfo EM,
      7         (SELECT ID, Workday, ChangeDate, NewShift
      8          FROM
      9                 (SELECT TC2.ID, TC2.Workday, SC2.ChangeDate, SC2.Newshift,
    10                         MAX (SC2.ChangeDate) KEEP (DENSE_RANK LAST ORDER BY SC2.ChangeDate)
    11                                              OVER (PARTITION BY SC2.ID, TC2.Workday) AS Max_ChangeDate
    12                  FROM   ShiftChanges SC2,
    13                         TimeCard TC2
    14                  WHERE  TC2.Workday >= SC2.ChangeDate
    15                  AND    TC2.ID = SC2.ID
    16                  )
    17          WHERE   ChangeDate = Max_ChangeDate
    18          ) SC
    19  WHERE  TC.ID=EM.ID(+) AND
    20         TC.ID=SC.ID(+) AND
    21         TC.Workday=SC.ChangeDate(+) AND
    22         TC.Workday = SC.Workday(+);
            ID NAME                             WORKDAY   SHIFT
           100 John Doe                         01-JAN-10 Days
           100 John Doe                         02-JAN-10 Nights
           100 John Doe                         03-JAN-10 Days
           101 Jane Doe                         01-JAN-10 Days
           101 Jane Doe                         02-JAN-10 Days
           101 Jane Doe                         03-JAN-10 Days
    6 rows selected.The inline view finds the greatest ChangeDate less than the TimeCard Workday for each Workday.

  • Read optimization time-series data

    I am using Berkeley DB JE to store fairly high frequency (10hz) time-series data collected from ~80 sensors. The idea is to import a large number of csv files with this data, and allow quick access to time ranges of data to plot with a web front end. I have created a "sample" entity to hold these sampled metrics, indexed by the time stamp. My entity looks like this.
    @Entity
    public class Sample {
         // Unix time; seconds since Unix epoch
         @PrimaryKey
         private double time;
         private Map<String, Double> metricMap = new LinkedHashMap<String, Double>();
    as you can see, there is quite a large amount of data for each entity (~70 - 80 doubles), and I'm not sure storing them in this way is best. This is my first question.
    I am accessing the db from a web front end. I am not too worried about insertion performance, as this doesn't happen that often, and generally all at one time in bulk. For smaller ranges (~1-2 hr worth of samples) the read performance is decent enough for web calls. For larger ranges, the read operations take quite a while. What would be the best approach for configuring this application?
    Also, I want to define granularity of samples. Basically, If the number of samples returned by a query is very large, I want to only return a fraction of the samples. Is there an easy way to count the number of entities that will be iterated over with a cursor without actually iterating over them?
    Here are my current configuration params.
    environmentConfig.setAllowCreateVoid(true);
              environmentConfig.setTransactionalVoid(true);
              environmentConfig.setTxnNoSyncVoid(true);
              environmentConfig.setCacheModeVoid(CacheMode.EVICT_LN);
              environmentConfig.setCacheSizeVoid(1000000000);
              databaseConfig.setAllowCreateVoid(true);
              databaseConfig.setTransactionalVoid(true);
              databaseConfig.setCacheModeVoid(CacheMode.EVICT_LN);

    Hi Ben, sorry for the slow response.
    as you can see, there is quite a large amount of data for each entity (~70 - 80 doubles), and I'm not sure storing them in this way is best. This is my first question.That doesn't sound like a large record, so I don't see a problem. If the map keys are repeated in each record, that's wasted space that you might want to store differently.
    For larger ranges, the read operations take quite a while. What would be the best approach for configuring this application?What isolation level do you require? Do you need the keys and the data? If the amount you're reading is a significant portion of the index, have you looked at using DiskOrderedCursor?
    Also, I want to define granularity of samples. Basically, If the number of samples returned by a query is very large, I want to only return a fraction of the samples. Is there an easy way to count the number of entities that will be iterated over with a cursor without actually iterating over them?Not currently. Using the DPL, reading with a key-only cursor is the best available option. If you want to drop down to the base API, you can use Cursor.skipNext and skipPrev, which are further optimized.
    environmentConfig.setAllowCreateVoid(true);Please use the method names without the Void suffix -- those are just for bean editors.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Frameaccess.java - time of presentation of each frame

    i've found frameaccess, which introduces a plugin in transcoding phase of processing.my question are, (i'm a newbie of jmf) it's possibile to modify in the code below the processor to have in shell display,time of presentation of each frame?another question is :it's possible to modify framerate and bit x pixel of output?
    thanks
    ////////////code
    * @(#)FrameAccess.java     1.5 01/03/13
    * Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
    * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
    * modify and redistribute this software in source and binary code form,
    * provided that i) this copyright notice and license appear on all copies of
    * the software; and ii) Licensee does not utilize the software in a manner
    * which is disparaging to Sun.
    * This software is provided "AS IS," without a warranty of any kind. ALL
    * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
    * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
    * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
    * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
    * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
    * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
    * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
    * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
    * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
    * POSSIBILITY OF SUCH DAMAGES.
    * This software is not designed or intended for use in on-line control of
    * aircraft, air traffic, aircraft navigation or aircraft communications; or in
    * the design, construction, operation or maintenance of any nuclear
    * facility. Licensee represents and warrants that it will not use or
    * redistribute the Software for such purposes.
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.TrackControl;
    import javax.media.Format;
    import javax.media.format.*;
    * Sample program to access individual video frames by using a
    * "pass-thru" codec. The codec is inserted into the data flow
    * path. As data pass through this codec, a callback is invoked
    * for each frame of video data.
    public class FrameAccess extends Frame implements ControllerListener {
    Processor p;
    Object waitSync = new Object();
    boolean stateTransitionOK = true;
    * Given a media locator, create a processor and use that processor
    * as a player to playback the media.
    * During the processor's Configured state, two "pass-thru" codecs,
    * PreAccessCodec and PostAccessCodec, are set on the video track.
    * These codecs are used to get access to individual video frames
    * of the media.
    * Much of the code is just standard code to present media in JMF.
    public boolean open(MediaLocator ml) {
         try {
         p = Manager.createProcessor(ml);
         } catch (Exception e) {
         System.err.println("Failed to create a processor from the given url: " + e);
         return false;
         p.addControllerListener(this);
         // Put the Processor into configured state.
         p.configure();
         if (!waitForState(p.Configured)) {
         System.err.println("Failed to configure the processor.");
         return false;
         // So I can use it as a player.
         p.setContentDescriptor(null);
         // Obtain the track controls.
         TrackControl tc[] = p.getTrackControls();
         if (tc == null) {
         System.err.println("Failed to obtain track controls from the processor.");
         return false;
         // Search for the track control for the video track.
         TrackControl videoTrack = null;
         for (int i = 0; i < tc.length; i++) {
         if (tc.getFormat() instanceof VideoFormat) {
              videoTrack = tc[i];
              break;
         if (videoTrack == null) {
         System.err.println("The input media does not contain a video track.");
         return false;
         System.err.println("Video format: " + videoTrack.getFormat());
         // Instantiate and set the frame access codec to the data flow path.
         try {
         Codec codec[] = { new PreAccessCodec(),
                        new PostAccessCodec()};
         videoTrack.setCodecChain(codec);
         } catch (UnsupportedPlugInException e) {
         System.err.println("The process does not support effects.");
         // Realize the processor.
         p.prefetch();
         if (!waitForState(p.Prefetched)) {
         System.err.println("Failed to realize the processor.");
         return false;
         // Display the visual & control component if there's one.
         setLayout(new BorderLayout());
         Component cc;
         Component vc;
         if ((vc = p.getVisualComponent()) != null) {
         add("Center", vc);
         if ((cc = p.getControlPanelComponent()) != null) {
         add("South", cc);
         // Start the processor.
         p.start();
         setVisible(true);
         return true;
    public void addNotify() {
         super.addNotify();
         pack();
    * Block until the processor has transitioned to the given state.
    * Return false if the transition failed.
    boolean waitForState(int state) {
         synchronized (waitSync) {
         try {
              while (p.getState() != state && stateTransitionOK)
              waitSync.wait();
         } catch (Exception e) {}
         return stateTransitionOK;
    * Controller Listener.
    public void controllerUpdate(ControllerEvent evt) {
         if (evt instanceof ConfigureCompleteEvent ||
         evt instanceof RealizeCompleteEvent ||
         evt instanceof PrefetchCompleteEvent) {
         synchronized (waitSync) {
              stateTransitionOK = true;
              waitSync.notifyAll();
         } else if (evt instanceof ResourceUnavailableEvent) {
         synchronized (waitSync) {
              stateTransitionOK = false;
              waitSync.notifyAll();
         } else if (evt instanceof EndOfMediaEvent) {
         p.close();
         System.exit(0);
    * Main program
    public static void main(String [] args) {
         if (args.length == 0) {
         prUsage();
         System.exit(0);
         String url = args[0];
         if (url.indexOf(":") < 0) {
         prUsage();
         System.exit(0);
         MediaLocator ml;
         if ((ml = new MediaLocator(url)) == null) {
         System.err.println("Cannot build media locator from: " + url);
         System.exit(0);
         FrameAccess fa = new FrameAccess();
         if (!fa.open(ml))
         System.exit(0);
    static void prUsage() {
         System.err.println("Usage: java FrameAccess <url>");
    * Inner class.
    * A pass-through codec to access to individual frames.
    public class PreAccessCodec implements Codec {
    * Callback to access individual video frames.
         void accessFrame(Buffer frame) {
         // For demo, we'll just print out the frame #, time &
         // data length.
         long t = (long)(frame.getTimeStamp()/10000000f);
         System.err.println("Pre: frame #: " + frame.getSequenceNumber() +
                   ", time: " + ((float)t)/100f +
                   ", len: " + frame.getLength());
         * The code for a pass through codec.
         // We'll advertize as supporting all video formats.
         protected Format supportedIns[] = new Format [] {
         new VideoFormat(null)
         // We'll advertize as supporting all video formats.
         protected Format supportedOuts[] = new Format [] {
         new VideoFormat(null)
         Format input = null, output = null;
         public String getName() {
         return "Pre-Access Codec";
         // No op.
    public void open() {
         // No op.
         public void close() {
         // No op.
         public void reset() {
         public Format [] getSupportedInputFormats() {
         return supportedIns;
         public Format [] getSupportedOutputFormats(Format in) {
         if (in == null)
              return supportedOuts;
         else {
              // If an input format is given, we use that input format
              // as the output since we are not modifying the bit stream
              // at all.
              Format outs[] = new Format[1];
              outs[0] = in;
              return outs;
         public Format setInputFormat(Format format) {
         input = format;
         return input;
         public Format setOutputFormat(Format format) {
         output = format;
         return output;
         public int process(Buffer in, Buffer out) {
         // This is the "Callback" to access individual frames.
         accessFrame(in);
         // Swap the data between the input & output.
         Object data = in.getData();
         in.setData(out.getData());
         out.setData(data);
         // Copy the input attributes to the output
         out.setFormat(in.getFormat());
         out.setLength(in.getLength());
         out.setOffset(in.getOffset());
         return BUFFER_PROCESSED_OK;
         public Object[] getControls() {
         return new Object[0];
         public Object getControl(String type) {
         return null;
    public class PostAccessCodec extends PreAccessCodec {
         // We'll advertize as supporting all video formats.
         public PostAccessCodec() {
         supportedIns = new Format [] {
              new RGBFormat()
    * Callback to access individual video frames.
         void accessFrame(Buffer frame) {
         // For demo, we'll just print out the frame #, time &
         // data length.
         long t = (long)(frame.getTimeStamp()/10000000f);
         System.err.println("Post: frame #: " + frame.getSequenceNumber() +
                   ", time: " + ((float)t)/100f +
                   ", len: " + frame.getLength());
         public String getName() {
         return "Post-Access Codec";

    Alternatives to iPhoto's slideshow include:
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $99
    Final Cut Pro X $299
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Pro X is the most capable app of them all. You get what you pay for.

Maybe you are looking for

  • Loading problems.

    Hi All, In my Production system, i just ran an full upload from source system  to  BW dso and from dso i triggerred an delta to cube Now i found that there is no use of this uploads and it disturbed the values in cube. i have a proposal 1. to delete 

  • FBL5N - in Rule set - It is a Display customer line items

    Dear All, We observed that FBL5N - Display customer line items in Standard SoD rule set under function AR07  addressing a risk of S022. Unless there are t-codes of FD03 or FB02 this t-code does not allow to change the payment terms of the customer. W

  • Adobe Acrobat / Reader 11.0.07 no longer renders dynamic pdf

    We have a number of dynamic XFA (PDF) forms we have sent out to end users. Those end users are in the process of upgrading to Adobe Acrobat or Reader 11.0.07 (Windows, Released 5/13). However upon upgrading, the users when opening the forms get a num

  • Need some help with ArrayLists...

    Hello, I am having trouble implementing the code requested by the following questions: 1. Suppose an ArrayList holds Comparable objects. Write a method that removes the smallest value from such a list. 2. Implement Selection Sort for an ArrayList of

  • Using brushes in .rar format (7.x version) in cs3

    I found just the brushes I was looking for in the exchange tonight but they are for photoshop version 7.x. I cannot get my photoshop cs3 product to recognize them. If anyone knows how to make this work, I would really appreciate it. Really. Thank you