Example usage for java.text SimpleDateFormat parse

List of usage examples for java.text SimpleDateFormat parse

Introduction

In this page you can find the example usage for java.text SimpleDateFormat parse.

Prototype

public Date parse(String source) throws ParseException 

Source Link

Document

Parses text from the beginning of the given string to produce a date.

Usage

From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.view.stadistics.EstadisticaUI.java

/**
 * @param args the command line arguments
 *//*from   w w  w  .  ja  v a2s.co m*/
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(EstadisticaUI.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(EstadisticaUI.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(EstadisticaUI.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(EstadisticaUI.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }
    //</editor-fold>

    /* Create and display the dialog */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                String startDate = "2014-07-04 18:14:29.000";
                String endDate = "2017-07-04 18:14:29.000";
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
                Date startD = dateFormat.parse(startDate);
                Date endD = dateFormat.parse(endDate);
                EstadisticaUI dialog = new EstadisticaUI(new javax.swing.JFrame(), true, startD, endD);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.pack();
                dialog.setVisible(true);
            } catch (ParseException ex) {
                Logger.getLogger(EstadisticaUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    });
}

From source file:Main.java

public static void main(String[] args) throws ParseException {

    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");

    String oeStartDateStr = "04/01/2015";
    String oeEndDateStr = "11/14/2015";

    Calendar cal = Calendar.getInstance();
    Integer year = cal.get(Calendar.YEAR);

    oeStartDateStr = oeStartDateStr.concat(year.toString());
    oeEndDateStr = oeEndDateStr.concat(year.toString());

    Date startDate = sdf.parse(oeStartDateStr);
    Date endDate = sdf.parse(oeEndDateStr);
    Date d = new Date();
    String currDt = sdf.format(d);

    if ((d.after(startDate) && (d.before(endDate)))
            || (currDt.equals(sdf.format(startDate)) || currDt.equals(sdf.format(endDate)))) {
        System.out.println("Date is between 1st april to 14th nov...");
    } else {/*from  www  .  j av a 2s . c  o m*/
        System.out.println("Date is not between 1st april to 14th nov...");
    }
}

From source file:de.tor.tribes.ui.algo.TimeFrameVisualizer.java

public static void main(String[] args) throws Exception {
    JFrame fr = new JFrame();
    SimpleDateFormat f = new SimpleDateFormat("dd.MM.yy HH:mm:ss");
    TimeFrame frame = new TimeFrame(f.parse("29.12.2010 22:00:00"), f.parse("29.12.2010 23:00:00"),
            f.parse("31.12.2010 19:53:00"), f.parse("31.12.2010 22:53:00"));
    //frame.addStartTimeSpan(new TimeSpan(new IntRange(0, 1)));
    frame.addStartTimeSpan(new TimeSpan(new IntRange(17, 24)));
    //  frame.addStartTimeSpan(new TimeSpan(f.parse("30.12.2010 00:00:00"), new IntRange(8, 22), Barbarians.getSingleton()));
    // frame.addStartTimeSpan(new TimeSpan(f.parse("30.12.2010 13:41:14")));

    // frame.addArriveTimeSpan(new TimeSpan(f.parse("30.12.2010 20:00:00")));
    TimeFrameVisualizer tfv = new TimeFrameVisualizer();

    JScrollPane sp = new JScrollPane(tfv);
    tfv.setScrollPane(sp);/*from  w  w w  .  j a va  2  s.  c  om*/
    fr.add(sp);

    fr.pack();
    fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tfv.refresh(frame);
    fr.setVisible(true);
}

From source file:com.bialx.ebics.FDL.java

public static void main(String[] args) throws Exception {
    String userId = "";
    Boolean isTest = false;/*from   ww  w.jav a 2  s .co  m*/
    Date startDate = null;
    Date endDate = null;

    SimpleDateFormat dtFormat = new SimpleDateFormat("yyyyMMdd");

    CommandLineParser parser = new DefaultParser();

    BialxOptions options = new BialxOptions();

    // Parse the program arguments
    CommandLine commandLine = parser.parse(options, args);

    // optional values
    if (commandLine.hasOption('s')) {
        startDate = dtFormat.parse(commandLine.getOptionValue('s'));
    }

    if (commandLine.hasOption('e')) {
        endDate = dtFormat.parse(commandLine.getOptionValue('e'));
    }

    if (commandLine.hasOption('t')) {
        isTest = true;
    }

    FDL fdl;
    PasswordCallback pwdHandler;
    Product product;

    fdl = new FDL();

    pwdHandler = new UserPasswordHandler(userId, CERT_PASSWORD);

    product = new Product("Bial-x EBICS FDL", Locale.FRANCE, null);

    if (commandLine.hasOption(BialxOptions.OPTION_CREATION)
            && !commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) {
        if (options.checkCreationOptions(commandLine)) {
            CreationOptions co = options.loadCreationOptions(commandLine);
            fdl.configuration.getLogger().info(String.format("Banque : %s", co.getBankName()));
            fdl.configuration.getLogger().info(String.format("Host : %s", co.getHostId()));
            fdl.configuration.getLogger().info(String.format("URL : %s", co.getBankUrl()));
            fdl.configuration.getLogger().info(String.format("Partner : %s", co.getPartnerId()));
            fdl.configuration.getLogger().info(String.format("User : %s", co.getUserId()));
            User user = fdl.createUser(co.getUserId(), co.getHostId(), co.getPartnerId(), co.getBankName(),
                    co.getBankUrl(), pwdHandler);
            fdl.sendHPBRequest(user, product);
        } else {
            fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande.");
            System.exit(0);
        }
    }

    if (!commandLine.hasOption(BialxOptions.OPTION_CREATION)
            && commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) {
        if (options.checkDownloadOptions(commandLine)) {
            DownloadOptions dop = options.loadDownloadOptions(commandLine);
            fdl.configuration.getLogger().info(String.format("Banque : %s", dop.getHostId()));
            fdl.configuration.getLogger().info(String.format("Host : %s", dop.getHostId()));
            fdl.configuration.getLogger().info(String.format("Partner : %s", dop.getPartnerId()));
            fdl.configuration.getLogger().info(String.format("User : %s", dop.getUserId()));
            fdl.configuration.getLogger().info(String.format("Format : %s", dop.getFormat()));
            fdl.configuration.getLogger().info(String.format("Destination : %s", dop.getDestination()));
            if (startDate != null) {
                fdl.configuration.getLogger()
                        .info(String.format("Date dbut : %s", dtFormat.format(startDate)));
            }
            if (endDate != null) {
                fdl.configuration.getLogger().info(String.format("Date fin : %s", dtFormat.format(endDate)));
            }
            fdl.loadUser(dop.getHostId(), dop.getPartnerId(), dop.getUserId(), pwdHandler);
            fdl.fetchFile(dop.getDestination(), dop.getUserId(), dop.getFormat(), product, OrderType.FDL,
                    isTest, startDate, endDate);
        } else {
            fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande.");
            System.exit(0);
        }
    }

    if (commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)
            && commandLine.hasOption(BialxOptions.OPTION_CREATION)) {
        fdl.configuration.getLogger().error("Impossible d'avoir les options C et D dans la mme commande.");
        System.exit(0);
    }

    fdl.quit();
}

From source file:my.yelp.populate.java

public static void main(String[] args)
        throws FileNotFoundException, ParseException, IOException, java.text.ParseException {
    try {/*from w w w.ja v  a 2  s.c o  m*/

        DbConnection A1 = new DbConnection();
        Connection con = A1.getConnection();

        JSONParser jsonParser;
        jsonParser = new JSONParser();

        Object obj1 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_user.json"));
        Object obj2 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_business.json"));
        Object obj3 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_review.json"));
        Object obj4 = jsonParser.parse(new FileReader("C:\\Users\\Sanjay Desai\\Desktop\\yelp_checkin.json"));

        JSONArray jsonArray1;
        jsonArray1 = (JSONArray) obj1;

        JSONArray jsonArray2;
        jsonArray2 = (JSONArray) obj2;

        JSONArray jsonArray3;
        jsonArray3 = (JSONArray) obj3;

        JSONArray jsonArray4;
        jsonArray4 = (JSONArray) obj4;

        // yelp_user
        String yelping_since, name1, user_id, type1;
        Long review_count1, fans;
        Double average_stars;
        Statement stmt;

        stmt = con.createStatement();
        stmt.executeUpdate("Delete from N_User");

        for (int i = 0; i < (jsonArray1.size()); i++)

        {
            JSONObject jsonObject = (JSONObject) jsonArray1.get(i);
            yelping_since = (String) jsonObject.get("yelping_since") + "-01";

            JSONArray friends = (JSONArray) jsonObject.get("friends");
            int friends_size = friends.size();

            review_count1 = (Long) jsonObject.get("review_count");
            name1 = (String) jsonObject.get("name");
            user_id = (String) jsonObject.get("user_id");
            fans = (Long) jsonObject.get("fans");
            average_stars = (Double) jsonObject.get("average_stars");
            type1 = (String) jsonObject.get("type");

            try (PreparedStatement pstmt1 = con.prepareStatement(
                    "Insert INTO N_User(yelping_since,friends_size,review_count,name,user_id,fans,average_stars,type) VALUES(?,?,?,?,?,?,?,?)")) {

                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                java.util.Date myDate = format.parse(yelping_since);

                pstmt1.setDate(1, new java.sql.Date(myDate.getTime()));
                pstmt1.setInt(2, friends_size);
                pstmt1.setLong(3, review_count1);
                pstmt1.setString(4, name1);
                pstmt1.setString(5, user_id);
                pstmt1.setLong(6, fans);
                pstmt1.setDouble(7, average_stars);
                pstmt1.setString(8, type1);
                pstmt1.executeUpdate();
            } catch (java.text.ParseException ex) {
                Logger.getLogger(populate.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        //yelp_business

        String business_id, address, city, state, name, type_business;

        Double stars;

        for (int i = 0; i < jsonArray2.size(); i++) {
            JSONObject jsonObject = (JSONObject) jsonArray2.get(i);
            business_id = (String) jsonObject.get("business_id");
            address = (String) jsonObject.get("full_address");
            city = (String) jsonObject.get("city");
            state = (String) jsonObject.get("state");
            name = (String) jsonObject.get("name");
            stars = (Double) jsonObject.get("stars");
            type_business = (String) jsonObject.get("type");

            try (PreparedStatement pstmt2 = con.prepareStatement(
                    "Insert INTO N_Business(business_id,address,city,state,name,stars,type_business) VALUES(?,?,?,?,?,?,?)")) {
                pstmt2.setString(1, business_id);
                pstmt2.setString(2, address);
                pstmt2.setString(3, city);
                pstmt2.setString(4, state);
                pstmt2.setString(5, name);
                pstmt2.setDouble(6, stars);
                pstmt2.setString(7, type_business);
                pstmt2.executeUpdate();
                pstmt2.close();
            }

        }

        //Category Table
        String[] categories = { "Active Life", "Arts & Entertainment", "Automotive", "Car Rental", "Cafes",
                "Beauty & Spas", "Convenience Stores", "Dentists", "Doctors", "Drugstores", "Department Stores",
                "Education", "Event Planning & Services", "Flowers & Gifts", "Food", "Health & Medical",
                "Home Services", "Home & Garden", "Hospitals", "Hotels & travel", "Hardware stores", "Grocery",
                "Medical Centers", "Nurseries & Gardening", "Nightlife", "Restaurants", "Shopping",
                "Transportation" };

        JSONArray category;
        String[] individual_category = new String[100];
        int count = 0, flag = 0, m = 0, n = 0;
        String[] business_category = new String[50];
        String[] subcategory = new String[50];

        for (int i = 0; i < jsonArray2.size(); i++) {
            JSONObject jsonObject3 = (JSONObject) jsonArray2.get(i);
            String business_id2 = (String) jsonObject3.get("business_id");
            category = (JSONArray) jsonObject3.get("categories");
            for (int j = 0; j < category.size(); j++) {
                individual_category[j] = (String) category.get(j);
                count = count + 1;
            }
            for (int k = 0; k < count; k++) {
                for (String categorie : categories) {

                    if (individual_category[k].equals(categorie)) {
                        flag = 1;
                        break;
                    }
                }
                if (flag == 1) {
                    business_category[m] = individual_category[k];
                    m = m + 1;
                    flag = 0;
                } else {
                    subcategory[n] = individual_category[k];
                    n = n + 1;
                }
            }
            for (int p = 0; p < m; p++) {
                for (int q = 0; q < n; q++) {
                    try (PreparedStatement pstmt3 = con.prepareStatement(
                            "INSERT INTO N_Category(business_id,category,subcategory) VALUES(?,?,?)")) {
                        pstmt3.setString(1, business_id2);
                        pstmt3.setString(2, business_category[p]);
                        pstmt3.setString(3, subcategory[q]);
                        pstmt3.executeUpdate();

                    }
                }
            }
            count = 0;
            m = 0;
            n = 0;
        }

        //yelp_review

        String user_id3, review_id, type3, business_id3, text, text1, review_date;
        Long stars3;
        int votes = 0;
        Integer no_votes;

        JSONObject votes_info;
        Set<String> keys;

        for (int i = 0; i < jsonArray3.size(); i++) {
            JSONObject jsonObject = (JSONObject) jsonArray3.get(i);

            votes_info = (JSONObject) jsonObject.get("votes");
            keys = votes_info.keySet();
            for (String r_key : keys) {
                votes = (int) (votes + (Long) votes_info.get(r_key));
            }
            no_votes = toIntExact(votes);
            user_id3 = (String) jsonObject.get("user_id");

            review_id = (String) jsonObject.get("review_id");
            business_id3 = (String) jsonObject.get("business_id");
            review_date = (String) jsonObject.get("date");
            text1 = (String) jsonObject.get("text");
            text = text1.substring(0, Math.min(1000, text1.length()));
            stars3 = (Long) jsonObject.get("stars");
            type3 = (String) jsonObject.get("type");

            try (PreparedStatement pstmt4 = con.prepareStatement(
                    "Insert INTO N_Review(no_votes,user_id,review_id,business_id,review_date,text,stars,type) VALUES(?,?,?,?,?,?,?,?)")) {
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
                java.util.Date myDate = format.parse(review_date);

                pstmt4.setInt(1, no_votes);
                pstmt4.setString(2, user_id3);
                pstmt4.setString(3, review_id);
                pstmt4.setString(4, business_id3);
                pstmt4.setDate(5, new java.sql.Date(myDate.getTime()));
                pstmt4.setString(6, text);
                pstmt4.setLong(7, stars3);
                pstmt4.setString(8, type3);
                pstmt4.executeUpdate();
                pstmt4.close();
            }

        }

        //Checkin_Info
        JSONObject checkin_info;
        String business_id4;
        Long check_in_count;
        Set<String> keys1;
        String[] timing = new String[10];
        int n1 = 0, time, hour;

        //Inserting into checkin_info
        for (int i = 0; i < jsonArray4.size(); i++) {
            JSONObject jsonObject4 = (JSONObject) jsonArray4.get(i);
            checkin_info = (JSONObject) jsonObject4.get("checkin_info");
            business_id4 = (String) jsonObject4.get("business_id");
            keys1 = checkin_info.keySet();

            for (String key : keys1) {
                check_in_count = (Long) checkin_info.get(key);
                for (String x : key.split("-")) {
                    timing[n1] = x;
                    n1 = n1 + 1;
                }
                n1 = 0;
                hour = Integer.parseInt(timing[0]);
                time = Integer.parseInt(timing[1]);

                try (PreparedStatement pstmt5 = con.prepareStatement(
                        "INSERT INTO check_info(business_id,hour,day,check_in_count)VALUES(?,?,?,?)")) {
                    pstmt5.setString(1, business_id4);
                    pstmt5.setInt(2, hour);
                    pstmt5.setInt(3, time);
                    pstmt5.setLong(4, check_in_count);
                    pstmt5.executeUpdate();
                }
            }

        }

        con.close();

    } catch (SQLException ex) {
        Logger.getLogger(populate.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.krawler.common.timezone.Timezone.java

public static void main(String[] args) {
    Connection conn = null;/* w w  w  . jav a 2 s .c  om*/
    try {
        java.util.Date post_time = Timezone.getGmtDate();
        java.sql.Timestamp sqlPostDate = new java.sql.Timestamp(post_time.getTime());
        conn = DbPool.getConnection();
        String c = "examdate";
        String t = "lexamschedule";
        String tZ = "+08:00";
        Date gmtDate = getGmtDate();
        String date = "2008-05-21";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-dd-MM");
        //            sdf.parse(date);
        Date newGmtDate = getGmtDate(sdf.parse(date));
        //String date = "2008-05-21 15:30:00";
        String uid = "08b18f8b-86ca-4d5b-a7a0-f576d50e7cb0"; //timezone == 2
        System.out.println(getGmtDate(conn, date, uid));

    } catch (Exception e) {
        System.out.println("You have an error: " + e);
    } finally {
        DbPool.quietClose(conn);
    }
}

From source file:uta.ak.ExecQuartzJob.java

public static void main(String[] args) throws Exception {

    SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("quartzContext.xml");
    Scheduler quartzScheduler = (Scheduler) applicationContext.getBean("quartzScheduler");

    JobDetail jobDetail = JobBuilder.newJob(CollectTwitterJob.class)
            .withIdentity("qrtz_job_collecttwitter", "qrtz_job_collecttwitter").build();
    SimpleScheduleBuilder builder = SimpleScheduleBuilder.simpleSchedule().repeatSecondlyForTotalCount(1000)
            .withIntervalInHours(24);/*  w ww.  jav a2 s.co m*/

    Trigger trigger = TriggerBuilder.newTrigger()
            .withIdentity("qrtz_trigger_collecttwitter", "qrtz_trigger_collecttwitter")
            .startAt(format1.parse("2016-08-03 00:05:00")).withSchedule(builder).build();

    //        quartzScheduler.scheduleJob(jobDetail, trigger);  
}

From source file:com.surfs.storage.web.controller.rest.block.BlockService.java

public static void main(String[] args) {
    String a = "Thu Jan 14 3:27 2016";
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm yyyy", Locale.US);//MMM dd hh:mm:ss Z yyyy
    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");//MMM dd hh:mm:ss Z yyyy
    try {/* ww  w . j a  v a 2  s. c  om*/
        System.out.println(sdf1.format(sdf.parse(a)));
    } catch (ParseException ex) {
        ex.printStackTrace();
    }
    System.out.println(System.getProperty("user.dir"));
}

From source file:com.icebreak.p2p.trade.impl.InvestServiceImpl.java

public static void main(String[] args) {
    int days = 56;
    Calendar endTime = Calendar.getInstance();
    Calendar beginTime = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date date = null;//from   w ww.  j a  v  a  2 s .  co  m
    try {
        date = sdf.parse("2015-01-27 09:49:21");
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    beginTime.setTime(date);
    int cutDays = (int) ((endTime.getTimeInMillis() - beginTime.getTimeInMillis()) / 1000 / 60 / 60 / 24);
    days = days - cutDays;
    days = (days < 0 ? 0 : days);
    System.out.println("cutDays: " + cutDays);
    System.out.println("days: " + days);
}

From source file:com.stumbleupon.hbaseadmin.HBaseCompact.java

/**
 * Main entry point//from  w  ww . ja v a 2s .  co m
 * @param args command line arguments
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    String hbaseSite = null;
    String jmxRemotePasswordFile = null;
    String jmxPort = null;
    Date startDate = null;
    Date endDate = null;
    int throttleFactor = 1;
    int numCycles = 1;
    int pauseInterval = DEFAULT_PAUSE_INTERVAL;
    int waitInterval = DEFAULT_WAIT_INTERVAL;
    int filesKeep = DEFAULT_FILES_KEEP;
    long regionCompactWaitTime = DEFAULT_REGION_COMPACT_WAIT_TIME;
    long maxStoreFileAge = 0;
    boolean excludeTables = false;
    String tableNamesString = "";
    List<String> tableNames = new ArrayList<String>();
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");

    // Parse command line options
    try {
        cmd = parser.parse(getOptions(), args);
    } catch (org.apache.commons.cli.ParseException e) {
        System.out.println(e.getMessage());
        printOptions();
        System.exit(-1);
    }

    for (Option option : cmd.getOptions()) {
        switch (option.getId()) {
        case 'c':
            hbaseSite = option.getValue();
            break;
        case 'j':
            jmxRemotePasswordFile = option.getValue();
            break;
        case 't':
            throttleFactor = Integer.parseInt(option.getValue());
            break;
        case 'n':
            numCycles = Integer.parseInt(option.getValue());
            break;
        case 'p':
            pauseInterval = Integer.parseInt(option.getValue());
            break;
        case 'w':
            waitInterval = Integer.parseInt(option.getValue());
            break;
        case 's':
            startDate = sdf.parse(option.getValue());
            break;
        case 'e':
            endDate = sdf.parse(option.getValue());
            break;
        case 'b':
            tableNamesString = option.getValue();
            tableNames = Arrays.asList(option.getValue().split(","));
            break;
        case 'f':
            filesKeep = Integer.parseInt(option.getValue());
            break;
        case 'r':
            jmxPort = option.getValue();
            break;
        case 'x':
            excludeTables = true;
            break;
        case 'm':
            regionCompactWaitTime = Long.parseLong(option.getValue());
            break;
        case 'a':
            maxStoreFileAge = Long.parseLong(option.getValue());
            break;
        default:
            throw new IllegalArgumentException("unexpected option " + option);
        }
    }

    LOG.info("Starting compactor");
    LOG.info("--------------------------------------------------");
    LOG.info("HBase site              : {}", hbaseSite);
    LOG.info("RegionServer Jmx port   : {}", jmxPort);
    LOG.info("Jmx password file       : {}", jmxRemotePasswordFile);
    LOG.info("Compact interval        : {}", pauseInterval);
    LOG.info("Check interval          : {}", waitInterval);
    LOG.info("Throttle factor         : {}", throttleFactor);
    LOG.info("Number of cycles        : {}", numCycles);
    LOG.info("Off-peak start time     : {}", Utils.dateString(startDate, "HH:mm"));
    LOG.info("Off-peak end time       : {}", Utils.dateString(endDate, "HH:mm"));
    LOG.info("Minimum store files     : {}", filesKeep);
    LOG.info("Table names             : {}", tableNamesString);
    LOG.info("Exclude tables          : {}", excludeTables);
    LOG.info("Region compact wait time: {}", regionCompactWaitTime);
    LOG.info("Max store file age      : {}", maxStoreFileAge);
    LOG.info("--------------------------------------------------");

    // Get command line options
    final Configuration conf = HBaseConfiguration.create();
    conf.addResource(new Path(hbaseSite));

    HBaseCompact compact = new HBaseCompact();
    ClusterUtils clusterUtils = new ClusterUtils(compact, regionCompactWaitTime);

    compact.setClusterUtils(clusterUtils);
    compact.setAdmin(new HBaseAdmin(conf));
    compact.setSleepBetweenCompacts(pauseInterval);
    compact.setSleepBetweenChecks(waitInterval);
    compact.setThrottleFactor(throttleFactor);
    compact.setNumCycles(numCycles);
    compact.setStartDate(startDate);
    compact.setEndDate(endDate);
    compact.setNumStoreFiles(filesKeep);
    compact.setTableNames(tableNames);
    compact.setExcludeTables(excludeTables);
    compact.setMaxStoreFileAge(maxStoreFileAge);

    clusterUtils.setJmxPort(jmxPort);
    clusterUtils.setJmxPasswordFile(jmxRemotePasswordFile);

    compact.runCompactions();
}