public static IsolatedEmploymentPeriod EmploymentPeriodExample2() {
   IsolatedEmploymentPeriod employmentPeriod = new IsolatedEmploymentPeriod();
   java.util.Calendar startCalendar = java.util.Calendar.getInstance();
   startCalendar.set(java.util.Calendar.MILLISECOND, 0);
   employmentPeriod.setStartDate(new java.sql.Date(startCalendar.getTime().getTime()));
   return employmentPeriod;
 }
Ejemplo n.º 2
0
    // Creates a new thread, runs the program in that thread, and reports any errors as needed.
    private void run(String clazz) {
      try {
        // Makes sure the JVM resets if it's already running.
        if (JVMrunning) kill();

        // Some String constants for java path and OS-specific separators.
        String separator = System.getProperty("file.separator");
        String path = System.getProperty("java.home") + separator + "bin" + separator + "java";

        // Tries to run compiled code.
        ProcessBuilder builder = new ProcessBuilder(path, clazz);

        // Should be good now! Everything past this is on you. Don't mess it up.
        println(
            "Build succeeded on " + java.util.Calendar.getInstance().getTime().toString(), progErr);
        println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", progErr);

        JVM = builder.start();

        // Note that as of right now, there is no support for input. Only output.
        Reader errorReader = new InputStreamReader(JVM.getErrorStream());
        Reader outReader = new InputStreamReader(JVM.getInputStream());
        // Writer inReader = new OutputStreamWriter(JVM.getOutputStream());

        redirectErr = redirectIOStream(errorReader, err);
        redirectOut = redirectIOStream(outReader, out);
        // redirectIn = redirectIOStream(null, inReader);
      } catch (Exception e) {
        // This catches any other errors we might get.
        println("Some error thrown", progErr);
        logError(e.toString());
        displayLog();
        return;
      }
    }
Ejemplo n.º 3
0
    // Kills the JVM process and any active threads on it.
    private void kill() {
      if (redirectErr != null) {
        redirectErr.close();
        redirectErr.interrupt();
      }

      if (redirectOut != null) {
        redirectOut.close();
        redirectOut.interrupt();
      }

      if (JVM != null) {
        JVM.destroy();
        JVM = null;
      }

      JVMrunning = false;

      println("JVM reset on " + java.util.Calendar.getInstance().getTime().toString(), progErr);
    }
 public void setTimestamp(RandomAccessFile ff) throws tinySQLException {
   try {
     java.util.Calendar cal = java.util.Calendar.getInstance();
     cal.setTime(new java.util.Date());
     int dd = cal.get(java.util.Calendar.DAY_OF_MONTH);
     int mm = cal.get(java.util.Calendar.MONTH) + 1;
     int yy = cal.get(java.util.Calendar.YEAR);
     yy = yy % 100; // Y2K problem: only 2 digits
     ff.seek(DATE_INDEX);
     ff.write(yy);
     ff.write(mm);
     ff.write(dd);
   } catch (Exception e) {
     throw new tinySQLException(e.getMessage());
   }
 }