// Path: app/src/main/java/gr/cryptocurrencies/bitcoinpos/utilities/DateUtilities.java
// public class DateUtilities {
// 
//     public final static String DATABASE_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
//     public final static String UTC = "UTC";
// 
//     public final static String USER_INTERFACE_DATE_FORMAT = "yyyy-MM-dd  HH:mm:ss";
// 
//     public static String getRelativeTimeString(String date) {
// 
//         // previously DB wasn't unix timestamp because of previous block explorer service didn't use it
//         //DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         //dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
//         DateFormat uiDf = new SimpleDateFormat(DateUtilities.USER_INTERFACE_DATE_FORMAT);
//         uiDf.setTimeZone(Calendar.getInstance().getTimeZone());
// 
//         long dbTimeInMillis = Long.parseLong(date);
//         long currentTimeInMillis = System.currentTimeMillis();
// 
//         Date dbDate = null;
//         dbDate = new Date((long) dbTimeInMillis*1000);
// 
//         // convert to friendly relative time string onl if difference less than 23 hours
//         String relativeTimeString;
//         if(currentTimeInMillis - dbTimeInMillis < 23*60*60 * 1000) {
//             // only get friendly relative string if we have a translation for that language
//             // Currently only Locale.ENGLISH
//             if(Locale.getDefault().getLanguage().equals( Locale.ENGLISH.toString() ) ||
//                     Locale.getDefault().getLanguage().equals( "el" )) {
//                 relativeTimeString = DateUtils.getRelativeTimeSpanString(dbTimeInMillis, currentTimeInMillis, DateUtils.MINUTE_IN_MILLIS).toString();
//             } else {
//                 relativeTimeString = dbDate != null ? uiDf.format(dbDate) : " -- ";
//             }
//         } else {
//             relativeTimeString = dbDate != null ? uiDf.format(dbDate) : " -- ";
//         }
// 
//         return relativeTimeString;
//     }
// 
//     public static String getDateAsString(Date date) {
//         DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
// 
//         return dbDf.format(date);
//     }
// 
//     public static Date getStringAsDate(String date) {
//         DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
// 
//         Date dbDate = null;
//         try {
//             dbDate = dbDf.parse(date);
//         } catch (ParseException e) {
//             e.printStackTrace();
//         }
// 
//         return dbDate;
//     }
// 
// 
// }


import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import java.util.List;
import gr.cryptocurrencies.bitcoinpos.utilities.DateUtilities;
package gr.cryptocurrencies.bitcoinpos.database;




public class ItemHelper {
    private static ItemHelper ourInstance = new ItemHelper();

    private static PointOfSaleDb mDbHelper;
    private static SQLiteDatabase mDb;

    public static ItemHelper getInstance(Context context) {
        if(mDbHelper == null) {
            mDbHelper = PointOfSaleDb.getInstance(context);
        }
        if(mDb == null) {
            mDb = mDbHelper.getWritableDatabase();
        }
        return ourInstance;
    }

    private ItemHelper() {
    }


    public int insert(Item item) {

        ContentValues values = new ContentValues();
        values.put(PointOfSaleDb.ITEMS_COLUMN_NAME, item.getName());
        values.put(PointOfSaleDb.ITEMS_COLUMN_AMOUNT, item.getAmount());
        values.put(PointOfSaleDb.ITEMS_COLUMN_IS_AVAILABLE, item.isAvailable());
        values.put(PointOfSaleDb.ITEMS_COLUMN_COLOR, item.getColor());
        values.put(PointOfSaleDb.ITEMS_COLUMN_DESCRIPTION, item.getDescription());
        values.put(PointOfSaleDb.ITEMS_COLUMN_DISPLAY_ORDER, item.getDisplayOrder());
// Path: app/src/main/java/gr/cryptocurrencies/bitcoinpos/utilities/DateUtilities.java
// public class DateUtilities {
// 
//     public final static String DATABASE_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
//     public final static String UTC = "UTC";
// 
//     public final static String USER_INTERFACE_DATE_FORMAT = "yyyy-MM-dd  HH:mm:ss";
// 
//     public static String getRelativeTimeString(String date) {
// 
//         // previously DB wasn't unix timestamp because of previous block explorer service didn't use it
//         //DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         //dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
//         DateFormat uiDf = new SimpleDateFormat(DateUtilities.USER_INTERFACE_DATE_FORMAT);
//         uiDf.setTimeZone(Calendar.getInstance().getTimeZone());
// 
//         long dbTimeInMillis = Long.parseLong(date);
//         long currentTimeInMillis = System.currentTimeMillis();
// 
//         Date dbDate = null;
//         dbDate = new Date((long) dbTimeInMillis*1000);
// 
//         // convert to friendly relative time string onl if difference less than 23 hours
//         String relativeTimeString;
//         if(currentTimeInMillis - dbTimeInMillis < 23*60*60 * 1000) {
//             // only get friendly relative string if we have a translation for that language
//             // Currently only Locale.ENGLISH
//             if(Locale.getDefault().getLanguage().equals( Locale.ENGLISH.toString() ) ||
//                     Locale.getDefault().getLanguage().equals( "el" )) {
//                 relativeTimeString = DateUtils.getRelativeTimeSpanString(dbTimeInMillis, currentTimeInMillis, DateUtils.MINUTE_IN_MILLIS).toString();
//             } else {
//                 relativeTimeString = dbDate != null ? uiDf.format(dbDate) : " -- ";
//             }
//         } else {
//             relativeTimeString = dbDate != null ? uiDf.format(dbDate) : " -- ";
//         }
// 
//         return relativeTimeString;
//     }
// 
//     public static String getDateAsString(Date date) {
//         DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
// 
//         return dbDf.format(date);
//     }
// 
//     public static Date getStringAsDate(String date) {
//         DateFormat dbDf = new SimpleDateFormat(DateUtilities.DATABASE_DATE_FORMAT);
//         dbDf.setTimeZone(TimeZone.getTimeZone(DateUtilities.UTC));
// 
//         Date dbDate = null;
//         try {
//             dbDate = dbDf.parse(date);
//         } catch (ParseException e) {
//             e.printStackTrace();
//         }
// 
//         return dbDate;
//     }
// 
// 
// }


// Path: app/src/main/java/gr/cryptocurrencies/bitcoinpos/database/ItemHelper.java
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import java.util.List;
import gr.cryptocurrencies.bitcoinpos.utilities.DateUtilities;

package gr.cryptocurrencies.bitcoinpos.database;




public class ItemHelper {
    private static ItemHelper ourInstance = new ItemHelper();

    private static PointOfSaleDb mDbHelper;
    private static SQLiteDatabase mDb;

    public static ItemHelper getInstance(Context context) {
        if(mDbHelper == null) {
            mDbHelper = PointOfSaleDb.getInstance(context);
        }
        if(mDb == null) {
            mDb = mDbHelper.getWritableDatabase();
        }
        return ourInstance;
    }

    private ItemHelper() {
    }


    public int insert(Item item) {

        ContentValues values = new ContentValues();
        values.put(PointOfSaleDb.ITEMS_COLUMN_NAME, item.getName());
        values.put(PointOfSaleDb.ITEMS_COLUMN_AMOUNT, item.getAmount());
        values.put(PointOfSaleDb.ITEMS_COLUMN_IS_AVAILABLE, item.isAvailable());
        values.put(PointOfSaleDb.ITEMS_COLUMN_COLOR, item.getColor());
        values.put(PointOfSaleDb.ITEMS_COLUMN_DESCRIPTION, item.getDescription());
        values.put(PointOfSaleDb.ITEMS_COLUMN_DISPLAY_ORDER, item.getDisplayOrder());
        values.put(PointOfSaleDb.ITEMS_COLUMN_CREATED_AT, DateUtilities.getDateAsString(item.getCreatedAt()));