Example usage for org.joda.time DateTime DateTime

List of usage examples for org.joda.time DateTime DateTime

Introduction

In this page you can find the example usage for org.joda.time DateTime DateTime.

Prototype

public DateTime() 

Source Link

Document

Constructs an instance set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:app.services.OfferService.java

License:Apache License

public void batchDeleteAndInsert(String asin, List<Offer> offers) {
    delete(asin);//  ww w .j  a va 2 s. c  o m
    for (Offer offer : offers) {
        offer.last_crawled = new DateTime();
        insert(offer);
    }
}

From source file:app.services.OfferService.java

License:Apache License

public Integer insert(Offer offer) {
    String sql = "";
    sql += "INSERT INTO offer (asin, cond, is_fba, no, price, shipping_costs, last_crawled, created) ";
    sql += "VALUES (:asin, :cond, :is_fba, :no, :price, :shipping_costs, :last_crawled, :created)";

    try (Connection con = sql2o.open()) {
        return con.createQuery(sql).addParameter("asin", offer.asin).addParameter("cond", offer.cond)
                .addParameter("is_fba", offer.is_fba).addParameter("no", offer.no)
                .addParameter("price", offer.price).addParameter("shipping_costs", offer.shipping_costs)
                .addParameter("last_crawled", offer.last_crawled).addParameter("created", new DateTime())
                .executeUpdate().getKey(Integer.class);
    }//from   w  w  w .j a  v a 2s.  c om
}

From source file:app.sunstreak.yourpisd.net.data.Student.java

License:Open Source License

/**
 * Loads the grade summary for the student.
 *//*  www . ja va2  s  . com*/
public void loadGradeSummary() throws IOException {
    Map<String, String> params = new HashMap<>();
    params.put("Student", "" + studentId);
    Parser.parseGradeSummary(session.request("/InternetViewer/GradeSummary.aspx", params), classes);
    lastUpdated = new DateTime();
}

From source file:app.sunstreak.yourpisd.util.DateHelper.java

License:Open Source License

public static String daysRelative(DateTime dt) {
    while (dt.isBefore(startOfSchoolYear))
        dt = dt.plusYears(1);/*from ww  w .  java 2  s.  c o m*/

    // if today
    if (dt.toLocalDate().isEqual(new LocalDate()))
        return "(today)";

    Period pd;
    if (dt.isBeforeNow())
        pd = new Interval(dt, new LocalDate().toDateTimeAtStartOfDay()).toPeriod();
    else
        pd = new Interval(new LocalDate().toDateTimeAtStartOfDay(), dt).toPeriod();
    StringBuilder sb = new StringBuilder("\n(");

    int compare = dt.compareTo(new DateTime());

    sb.append(pf.print(pd));
    // Compare to now.
    if (dt.isBeforeNow())
        sb.append(" ago)");
    else
        sb.append(" from now)");
    return sb.toString();
}

From source file:applango.common.services.DB.mongo.mongoDB.java

public static DBObject getRollupValue(DBCollection coll, String userId) {
    logger.info("Getting today's rollup record for user " + userId);
    DBCursor cursor;//from  www.  j  a  v a 2s. com
    int maxWait = 10;
    try {
        DateTime jsonToday = new DateTime();
        DateTime yesterday = new DateTime().minusDays(1);

        Date yesterdayDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse(yesterday.toString());
        BasicDBObject dateQueryObj = new BasicDBObject("beginDate", new BasicDBObject("$gt", yesterdayDate));
        dateQueryObj.append("userId", userId);
        dateQueryObj.append("customerId", "automationCustomer");
        dateQueryObj.append("appName", "salesforce");

        cursor = coll.find(dateQueryObj);

        while ((cursor.count() == 0) && maxWait > 0) {
            sleep(1000);
            maxWait--;
        }

    } catch (Exception ex) {
        cursor = null;
        logger.error(ex.getMessage());
    }
    return cursor.next();
}

From source file:ar.com.wolox.commons.base.datetime.CurrentDateTimeProvider.java

License:Apache License

@Override
public DateTime getDateTime() {
    return new DateTime();
}

From source file:assignment1b.main.Main.java

public static void main(String[] args) {
    DateTime dt = new DateTime();

    //add students    
    ArrayList<Student> stds = new ArrayList<Student>();

    Student std1 = new Student("John", "19", dt);
    stds.add(std1);//from ww w  . jav  a2  s  .co m
    Student std2 = new Student("Mary", "21", dt);
    stds.add(std2);
    Student std3 = new Student("David", "18", dt);
    stds.add(std3);
    Student std4 = new Student("Helen", "21", dt);
    stds.add(std4);
    Student std5 = new Student("Chris", "19", dt);
    stds.add(std5);
    Student std6 = new Student("Sarah", "19", dt);
    stds.add(std6);
    Student std7 = new Student("Joe", "18", dt);
    stds.add(std7);

    //add modules
    ArrayList<Module> mod = new ArrayList<Module>();

    Module CT111 = new Module("Programming", "CT111");
    CT111.StudentReg(std1);
    CT111.StudentReg(std4);
    CT111.StudentReg(std5);
    mod.add(CT111);

    Module CT222 = new Module("Database", "CT222");
    CT222.StudentReg(std2);
    CT222.StudentReg(std4);
    CT222.StudentReg(std6);
    mod.add(CT222);

    Module CT354 = new Module("Professional Skills", "CT354");
    CT354.StudentReg(std3);
    CT354.StudentReg(std4);
    CT354.StudentReg(std7);
    CT354.StudentReg(std1);
    mod.add(CT354);

    //add course
    Course BCT = new Course("Computer Science and IT", new DateTime(), new DateTime());
    BCT.setModules(mod);
    // Print our everything
    System.out.println(BCT);
}

From source file:at.florian_lentsch.expirysync.AddProductActivity.java

License:Open Source License

/**
 * Creates a {@link ProductEntry} from the form data
 * //from  ww w . j  a v  a  2 s.  co  m
 * @param article
 *            the article associated with the entry
 * @return the requested {@link ProductEntry}
 */
private ProductEntry createProductEntryFromFormData(Article article) {
    final ProductEntry productEntry = new ProductEntry();
    productEntry.article = article;

    EditText amountField = ((EditText) findViewById(R.id.amount_field));
    String amountStr = amountField.getText().toString();
    if (amountStr.trim().equals("")) {
        amountStr = DEFAULT_AMOUNT;
    }
    productEntry.amount = Integer.parseInt(amountStr);
    productEntry.created_at = new DateTime();
    productEntry.updated_at = new DateTime();
    productEntry.description = ((EditText) findViewById(R.id.product_description_field)).getText().toString();

    DatePicker datePicker = (DatePicker) findViewById(R.id.expiration_date_field);
    productEntry.expiration_date = (new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(),
            datePicker.getDayOfMonth())).getTime();
    productEntry.location = ProductListActivity.currentLocation;

    productEntry.inSync = false;

    return productEntry;
}

From source file:at.florian_lentsch.expirysync.EditProductActivity.java

License:Open Source License

/**
 * Deletes {@link #curEntry} from the local db and (if possible) from the server
 *//*  w ww .j  a  v a2s  .  c o m*/
private void deleteProduct() {
    final DatabaseManager dbManager = DatabaseManager.getInstance();

    final ServerProxy entryProxy = ServerProxy.getInstanceFromConfig(this);
    if (entryProxy.getCurrentUser() != null && this.curEntry.serverId > 0) {
        entryProxy.deleteProductEntry(this.curEntry, entryProxy.new ProductEntryCallback() {
            @Override
            public void onReceive(ProductEntry receivedEntry) {
                if (receivedEntry == null) {
                    Util.showMessage(EditProductActivity.this, "Deleting from server failed: ");
                }
            }
        });
        dbManager.deleteProductEntry(this.curEntry);
    } else {
        this.curEntry.deleted_at = new DateTime();
        this.curEntry.inSync = false;
        dbManager.updateProductEntry(this.curEntry);
    }

    this.curEntry = null;

    finishEditing();
}

From source file:at.florian_lentsch.expirysync.ProductListActivity.java

License:Open Source License

/**
 * Deletes all products that have been selected by checking their checkboxes.
 * The user has to answer 'yes' to a confirm dialog, else the operation is aborted.
 *///  w w  w .j a va2  s  .co m
private void deleteSelectedProducts() {
    new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.delete_selected_products).setMessage(R.string.really_delete_selected_products)
            .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final DatabaseManager dbManager = DatabaseManager.getInstance();

                    final ServerProxy entryProxy = ServerProxy.getInstanceFromConfig(ProductListActivity.this);
                    for (int i = 0; i < ProductListActivity.this.selectedEntries.size(); i++) {
                        int entryId = ProductListActivity.this.selectedEntries.keyAt(i);
                        ProductEntry entry = ProductListActivity.this.selectedEntries.get(entryId);

                        if (entryProxy.getCurrentUser() != null) {
                            entryProxy.deleteProductEntry(entry, entryProxy.new ProductEntryCallback() {
                                @Override
                                public void onReceive(ProductEntry receivedEntry) {
                                    if (receivedEntry == null) {
                                        Util.showMessage(ProductListActivity.this,
                                                "Deleting from server failed: ");
                                    }
                                }
                            });
                            dbManager.deleteProductEntry(entry);
                        } else {
                            entry.deleted_at = new DateTime();
                            entry.inSync = false;
                            dbManager.updateProductEntry(entry);
                        }
                    }

                    ProductListActivity.this.selectedEntries.clear();
                    ProductListActivity.this.setResult(RESULT_OK);
                    ProductListActivity.this.loadProductEntriesToList();
                    ProductListActivity.this.setAllEntriesChecked(false);
                }

            }).setNegativeButton(R.string.no, null).show();
}