Example usage for java.util Calendar toString

List of usage examples for java.util Calendar toString

Introduction

In this page you can find the example usage for java.util Calendar toString.

Prototype

@Override
public String toString() 

Source Link

Document

Return a string representation of this calendar.

Usage

From source file:org.betaconceptframework.astroboa.engine.jcr.dao.ContentDao.java

private Calendar checkModificationDateBeforeSave(ContentObject contentObject,
        boolean updateLastModificationTime, Calendar modifiedDateBeforeSave) {

    if (modifiedDateBeforeSave != null) {
        //Make a check if provided ContentObject has a different modified date
        if (contentObject.getComplexCmsRootProperty() != null
                && contentObject.getComplexCmsRootProperty().isChildPropertyLoaded("profile.modified")) {
            CalendarProperty modifiedDateProvidedByUserProperty = (CalendarProperty) contentObject
                    .getCmsProperty("profile.modified");

            boolean throwException = false;

            if (modifiedDateProvidedByUserProperty.hasValues()) {

                Calendar modifiedDateProvidedByUser = modifiedDateProvidedByUserProperty.getSimpleTypeValue();

                if (modifiedDateProvidedByUser == null || modifiedDateProvidedByUser
                        .getTimeInMillis() != modifiedDateBeforeSave.getTimeInMillis()) {
                    throwException = true;
                } else {
                    return modifiedDateBeforeSave;
                }// w w  w .ja  v a 2 s . c  om
            }

            if (throwException) {
                String pattern = "dd/MM/yyyy HH:mm:ss.SSSZ";
                throw new CmsConcurrentModificationException("Content Object " + contentObject.getId() + "/"
                        + contentObject.getSystemName()
                        + " has been concurrently modified by another user or current user has tried to "
                        + " set a value for  profile.modified property. \n"
                        + " profile.modified BEFORE save :   \t"
                        + DateUtils.format(modifiedDateBeforeSave, pattern) + "(full info "
                        + modifiedDateBeforeSave.toString() + ")\n"
                        + " profile.modified provided by user save : "
                        + (modifiedDateProvidedByUserProperty.hasNoValues() ? " No date "
                                : DateUtils.format(modifiedDateProvidedByUserProperty.getSimpleTypeValue(),
                                        pattern))
                        + "(full info " + modifiedDateProvidedByUserProperty.getSimpleTypeValue() + ")");
            }
        }
    }

    return null;
}

From source file:com.nest5.businessClient.Initialactivity.java

private void makeDailyTable(int TABLE_TYPE) {
    dailyTable.removeAllViews();/*from   w  ww. j a  v  a 2  s  . co  m*/
    Double total = 0.0;
    DecimalFormat dec = new DecimalFormat("$###,###,###");
    TextView tv = new TextView(mContext);
    tv.setBackgroundColor(Color.parseColor("#80808080"));
    tv.setHeight(2);
    TableRow tr1 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
    TextView tDate1 = (TextView) tr1.findViewById(R.id.cell_date);
    TextView tItem1 = (TextView) tr1.findViewById(R.id.cell_item);
    TextView tAccount1 = (TextView) tr1.findViewById(R.id.cell_account);
    TextView tVal1 = (TextView) tr1.findViewById(R.id.cell_value);
    TextView tTot1 = (TextView) tr1.findViewById(R.id.cell_total);
    tDate1.setText("FECHA");
    tAccount1.setText("CUENTA");
    tItem1.setText("ITEM");
    tVal1.setText("VALOR");
    tTot1.setText("TOTAL");
    tr1.setBackgroundColor(Color.CYAN);
    dailyTable.addView(tr1);
    dailyTable.addView(tv);

    //actualizar sales de hoy
    Calendar today = Calendar.getInstance();
    Calendar tomorrow = Calendar.getInstance();
    today.set(Calendar.HOUR, 0);
    today.set(Calendar.HOUR_OF_DAY, 0);
    today.set(Calendar.MINUTE, 0);
    today.set(Calendar.SECOND, 0);
    today.set(Calendar.MILLISECOND, 0);
    tomorrow.roll(Calendar.DATE, 1);
    tomorrow.set(Calendar.HOUR, 0);
    tomorrow.set(Calendar.HOUR_OF_DAY, 0);
    tomorrow.set(Calendar.MINUTE, 0);
    tomorrow.set(Calendar.SECOND, 0);
    tomorrow.set(Calendar.MILLISECOND, 0);

    init = today.getTimeInMillis();
    end = tomorrow.getTimeInMillis();
    Log.d("GUARDANDOVENTA", today.toString());
    Log.d("GUARDANDOVENTA", tomorrow.toString());
    Calendar now = Calendar.getInstance();
    now.setTimeInMillis(System.currentTimeMillis());
    Log.d(TAG, now.toString());

    Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init));
    salesFromToday = saleDataSource.getAllSalesWithin(init, end);

    List<Sale> usingSales = salesFromToday;

    switch (TABLE_TYPE) {
    case TABLE_TYPE_TODAY:
        usingSales = salesFromToday;
        break;
    case TABLE_TYPE_ALL:
        usingSales = saleList;
        break;
    }

    for (Sale currentSale : usingSales) {

        double totalLocal = 0.0;
        LinkedHashMap<Combo, Double> combos = currentSale.getCombos();
        LinkedHashMap<Product, Double> products = currentSale.getProducts();
        LinkedHashMap<Ingredient, Double> ingredients = currentSale.getIngredients();
        Log.w("DAYILETABLES", " " + combos.size() + " " + products.size() + " " + ingredients.size());
        Iterator<Entry<Combo, Double>> it = combos.entrySet().iterator();
        Calendar date = Calendar.getInstance();
        date.setTimeInMillis(currentSale.getDate());
        String fecha = date.get(Calendar.MONTH) + "/" + date.get(Calendar.DAY_OF_MONTH) + "/"
                + date.get(Calendar.YEAR) + "\n" + date.get(Calendar.HOUR_OF_DAY) + ":"
                + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND);
        String account = currentSale.getPaymentMethod();
        while (it.hasNext()) {
            TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
            TextView tDate = (TextView) tr.findViewById(R.id.cell_date);
            TextView tItem = (TextView) tr.findViewById(R.id.cell_item);
            TextView tAccount = (TextView) tr.findViewById(R.id.cell_account);
            TextView tVal = (TextView) tr.findViewById(R.id.cell_value);
            TextView tTot = (TextView) tr.findViewById(R.id.cell_total);
            Map.Entry<Combo, Double> pair = (Map.Entry<Combo, Double>) it.next();
            Double value = pair.getValue() * pair.getKey().getPrice();

            tDate.setText(fecha);
            tAccount.setText(account);
            tItem.setText(pair.getKey().getName() + " en Combo");
            tVal.setText(dec.format(value));
            tTot.setText("----");
            total += value;
            totalLocal += value;
            dailyTable.addView(tr);

            // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue());
        }

        Iterator<Entry<Product, Double>> it2 = products.entrySet().iterator();

        while (it2.hasNext()) {
            Map.Entry<Product, Double> pair = (Map.Entry<Product, Double>) it2.next();
            TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
            TextView tDate = (TextView) tr.findViewById(R.id.cell_date);
            TextView tItem = (TextView) tr.findViewById(R.id.cell_item);
            TextView tAccount = (TextView) tr.findViewById(R.id.cell_account);
            TextView tVal = (TextView) tr.findViewById(R.id.cell_value);
            TextView tTot = (TextView) tr.findViewById(R.id.cell_total);

            Double value = pair.getValue() * pair.getKey().getPrice();

            tDate.setText(fecha);
            tAccount.setText(account);
            tItem.setText(pair.getKey().getName());
            tVal.setText(dec.format(value));
            tTot.setText("----");
            total += value;
            totalLocal += value;
            dailyTable.addView(tr);

            // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue());
        }

        Iterator<Entry<Ingredient, Double>> it3 = ingredients.entrySet().iterator();

        while (it3.hasNext()) {
            Map.Entry<Ingredient, Double> pair = (Map.Entry<Ingredient, Double>) it3.next();
            TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
            TextView tDate = (TextView) tr.findViewById(R.id.cell_date);
            TextView tItem = (TextView) tr.findViewById(R.id.cell_item);
            TextView tAccount = (TextView) tr.findViewById(R.id.cell_account);
            TextView tVal = (TextView) tr.findViewById(R.id.cell_value);
            TextView tTot = (TextView) tr.findViewById(R.id.cell_total);

            Double value = pair.getValue() * pair.getKey().getPrice();

            tDate.setText(fecha);
            tAccount.setText(account);
            tItem.setText(pair.getKey().getName());
            tVal.setText(dec.format(value));
            tTot.setText("----");
            total += value;
            totalLocal += value;
            dailyTable.addView(tr);

            // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue());
        }

        TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
        TextView tDate = (TextView) tr.findViewById(R.id.cell_date);
        TextView tItem = (TextView) tr.findViewById(R.id.cell_item);
        TextView tAccount = (TextView) tr.findViewById(R.id.cell_account);
        TextView tVal = (TextView) tr.findViewById(R.id.cell_value);
        TextView tTot = (TextView) tr.findViewById(R.id.cell_total);

        tDate.setText(fecha);
        tAccount.setText("-------");
        tItem.setText("Ingreso por Ventas");
        tVal.setText("----");
        tTot.setText(dec.format(totalLocal));
        tr.setBackgroundColor(Color.LTGRAY);
        dailyTable.addView(tr);
        TableRow tr2 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null);
        TextView tDate2 = (TextView) tr2.findViewById(R.id.cell_date);
        TextView tItem2 = (TextView) tr2.findViewById(R.id.cell_item);
        TextView tAccount2 = (TextView) tr2.findViewById(R.id.cell_account);
        TextView tVal2 = (TextView) tr2.findViewById(R.id.cell_value);
        TextView tTot2 = (TextView) tr2.findViewById(R.id.cell_total);

        tDate2.setText(fecha);
        tAccount2.setText("-------");
        tItem2.setText("Acumulado por Ventas");
        tVal2.setText("----");
        tTot2.setText(dec.format(total));
        tr2.setBackgroundColor(Color.GRAY);
        dailyTable.addView(tr2);

    }

}