Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2013
    Location
    Wisconsin, USA
    Posts
    60
    Rep Power
    0

    Default Joda-Time file path problem

    I don't understand why it's still saying "package org.joda.time does not exist" about my joda-time DateTime import:

    Joda-Time file path problem-jodatimepath.png

    If you look at my file tree in the image above, I have specified the file path in my import statement. What's wrong?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Joda-Time file path problem

    Does a path exist like the package name?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Joda-Time file path problem

    Why oh why do you have the source distribution (as a zip file no less) in your project? You need the regular binary jar with the classes.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Join Date
    Jul 2013
    Location
    Wisconsin, USA
    Posts
    60
    Rep Power
    0

    Default Re: Joda-Time file path problem

    Quote Originally Posted by gimbal2 View Post
    Why oh why do you have the source distribution (as a zip file no less) in your project? You need the regular binary jar with the classes.
    Okay, unzipped:

    Joda-Time file path problem-joda-time-project-directory.png

    Which jar do i need to include, and where inside my project directory do I need to put it in:

    Joda-Time file path problem-joda-time-eclipse.png

    NOTE: switched to Eclipse IDE, because more people are familiar with it.
    Last edited by SamJava_the_Hut; 03-26-2014 at 02:54 AM.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,783
    Blog Entries
    7
    Rep Power
    21

    Default Re: Joda-Time file path problem

    Store the first .jar file anywhere you want on you hard disk; in Eclipse, right click on your project and select properties>Java build path>add external .jar. Find your .jar file and add it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    7

    Default Re: Joda-Time file path problem

    Have you heard and worked with Maven?

    I am certain that Maven will resolve all such problems. If you can not use maven, just download binary distributions of Joda and add as external jars for your project in build path.
    Mak
    (Living @ Virtual World)

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Joda-Time file path problem

    So you are suggesting to add an additional layer of complexity to a person who doesn't know yet how to work with jars in general? You can't fix lack of knowledge by throwing yet another tool at it, you have to buckle down and learn something.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    Join Date
    Jul 2013
    Location
    Wisconsin, USA
    Posts
    60
    Rep Power
    0

    Default Re: Joda-Time file path problem

    Quote Originally Posted by JosAH View Post
    Store the first .jar file anywhere you want on you hard disk; in Eclipse, right click on your project and select properties>Java build path>add external .jar. Find your .jar file and add it.

    kind regards,

    Jos
    Hi Jos. As it turns out, I needed to add an additional folder called "libs" to the root project folder of my directory. Details on my findings here:
    jodatime - Java Joda Time - download, and install - step by step - Stack Overflow

    But this is only the beginning. I've been struggling to create a time stamp for when an employee clocks in and clocks out, and I'm not having much luck finding any good code examples. Here's my pathetic attempts at creating time stamp code so far:

    Java Code:
    /*
     * This class prompts the employee to punch in or out. If the employee
     * punches in, it simply says that he is punched in, and good bye. if 
     * he punches out, it tells that employee how much he made that day, how
     * long he's been with the company, and good bye.
     */
    package employeepunch;
    import java.text.SimpleDateFormat;
    import java.util.Scanner;
    import java.util.Date;
    import java.util.Calendar;
    import java.util.StringTokenizer;
    import java.io.*;
    
    import org.joda.time.DateTime;
    import org.joda.time.Years;
    import org.joda.time.Months;
    import org.joda.time.Weeks;
    import org.joda.time.Days;
    import org.joda.time.Hours;
    import org.joda.time.Minutes;
    import org.joda.time.Seconds;
    
    //import EmployeeData.txt;
    /**
     *
     * @author Sam Peterson
     */
    public class EmployeePunch extends EmployeeInfo {
    
    	private String empToken = null;
    	private String Seniority;
    	private Double dailyTotal;
    	private TimeStamp clockIn;
        private TimeStamp clockOut;
        
    	
    	public EmployeePunch(String empNum, String fname, String lname,
    			String hired, Double pay, String token, String senior,
    			Double earn, TimeStamp in, TimeStamp out)
    {       
    super(empNum, fName, lName, hired, pay);//return parameters from EmployeeInfo class
    empToken = token;//convert each parameter from EmployeeData.txt into a token
    Seniority = senior;
    dailyTotal = earn;
    clockIn = in;
    clockOut = out;
    //NOTE: hired will need to be compared with clockOut timestamp to calculate seniority
    
    } 
        /**
         * @param args the command line arguments
         */
    	
    	//Global variable for recording clock in time:
        public DateTime timeStamp;	
    	
        public static void main(String[] args) {
            //1.)"Please Enter Employee Number."
            String employeeNum;  // To hold an employee id number
          
          // Create a Scanner object for keyboard input.
          Scanner keyboard = new Scanner(System.in);
          
          System.out.println("Enter a customer number in "
                             + "the form LLLNNNN");
          System.out.print("(LLL = letters and NNNN "
                           + "= numbers): ");
    
          // Get a customer number from the user.
          employeeNum = keyboard.nextLine();
          
          // Determine whether it is valid.
          if (isValid(employeeNum))
          {
             System.out.println("That's a valid customer "
                                + "number.");
          }
          else
          {
             System.out.println("That is not the proper "
                                + "format.");
             System.out.println("Here is an example: "
                                + "ABC1234");
          }
            
            //2.)"To Punch in, Press 1. To Punch out, press 2."
          /*
           * if 1 is pressed, simply say "Hello" + firstName + lastName ". You are"
           * + "punched in. Have a great day."
           * 
           * MAKE SURE A TIMER IS STARTED, SO THAT HIS WORK HOURS CAN BE USED TO
           * CALCULATE HIS PAY WHEN HE'S PUNCHING OUT!
           * 
           * if 2 is pressed, say "Thank you " + firstName + lastName ". You are"
           * + "punched out. You made " + dayTotal + "today. You've been with us "
           * + "for " + seniority_params_here + "Have a fantastic evening." 
           */
          
          public void calculatePay{
        	  SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              
        	  	Date d1 = null;
        	  	Date d2 = null;
        	   
        	  	try {
        	  		d1 = format.parse(dateStart);
        	  		d2 = format.parse(dateStop);
        	   
        	  		DateTime dt1 = new DateTime(d1);
        	  		DateTime dt2 = new DateTime(d2);
        	  		
        	      System.out.print(Hours.hoursBetween(dt1, dt2).getHours() % 24 + " hours, ");
        			System.out.print(Minutes.minutesBetween(dt1, dt2).getMinutes() % 60 + " minutes, ");
        			
        			
        	      
        	      //The best TimeStamp code I could find:
        	      public class Interval {
        	          private TimeStamp clockIn;
        	          private TimeStamp clockOut;
        	          
        	          public Interval(TimeStamp clockIn, TimeStamp clockOut) {
        	                  this.clockIn = clockIn;
        	                  this.clockOut = clockOut;
        	          }
        	          public TimeStamp getClockIn() {
        	                  return clockIn;
        	          }
        	          public void setClockIn(TimeStamp clockIn) {
        	                  this.clockIn = clockIn;
        	          }
        	          public TimeStamp getClockOut() {
        	                  return clockOut;
        	          }
        	          public void setClockOut(TimeStamp clockOut) {
        	                  this.clockOut = clockOut;
        	          }
        	          public int countMinutes() {
        	                  int day = clockOut.getDay() - clockIn.getDay();
        	                  int minutes = clockOut.getMinute() - clockIn.getMinute();
        	                  
        	                  int result = day*24*3600 + minutes;
        	                  return result;
        	          }
        	  }
        	  	} catch (Exception e) {
        			e.printStackTrace();
        		 }
        	    }
          
        }//end of main method
    I need to get the time interval between the clockIn and clockOut time stamps, so I can multiply it by the employee's hourly wage, and calculate his/her pay. Any ideas on how I should start cleaning it up?
    Last edited by SamJava_the_Hut; 03-27-2014 at 01:45 AM.

Similar Threads

  1. Getting started with joda.time
    By SamJava_the_Hut in forum New To Java
    Replies: 0
    Last Post: 10-15-2013, 05:18 AM
  2. Replies: 10
    Last Post: 09-13-2013, 09:41 PM
  3. Add a jar file to Java load path at run time
    By marioneil in forum Advanced Java
    Replies: 5
    Last Post: 09-22-2010, 08:58 AM
  4. problem in file path
    By jperson in forum New To Java
    Replies: 2
    Last Post: 01-15-2010, 12:26 PM
  5. Weird path problem when reading properties file
    By jerry_popperq in forum New To Java
    Replies: 0
    Last Post: 03-18-2009, 04:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •