Convert From Java Week To Sqlite Week : SQLiteDatabase « Database « Android






Convert From Java Week To Sqlite Week

    
//package org.avelino.mobile.android.budgetfrik;

import java.text.NumberFormat;
import java.util.Stack;

import android.view.View;
import android.view.ViewGroup;

/**
 * License http://creativecommons.org/licenses/by-nc-sa/2.5/se/deed.en_US
 * See assets/license.html
 * @author Avelino Benavides
 *
 */
class Utils {
  private static final NumberFormat NUMBER_WEEK = NumberFormat.getNumberInstance();
  @SuppressWarnings("unused")
  private static final String TAG = "BudgetFrik.Utils";
  static{
    NUMBER_WEEK.setMinimumIntegerDigits(2);
    NUMBER_WEEK.setMaximumIntegerDigits(2);
  }
  
  private Utils(){}
  
  public static String convertFromJavaWeekToSqliteWeek(String yyyy_ww){
    String [] split = yyyy_ww.split("-");
    return split[0] + "-" + NUMBER_WEEK.format(Integer.parseInt(split[1])-1);
  }
  
  
  public interface Clause<K,V>{
    public V evaluate(K k);
  }
  
  public static <K extends View>  K findViewInHierarchy(ViewGroup parent, final Class<K> claz,
                                final Clause<K, Boolean> clause){
    
    K result = null;
    Stack<ViewGroup> parents = new Stack<ViewGroup>();
    while (result == null ){
      int childCount = parent.getChildCount();
      for (int i = 0; i< childCount; i++){
        final View childAt = parent.getChildAt(i);
        if (claz.isInstance(childAt) && 
          clause.evaluate(claz.cast(childAt))){
          result =  claz.cast(childAt);
          break;
        }
        if (childAt instanceof ViewGroup){
          parents.push((ViewGroup) childAt);
        }
      }
      if (!parents.isEmpty()){
        parent = parents.pop();
      } else {
        break;
      }
    }
    return result;
  }
  
}

   
    
    
    
  








Related examples in the same category

1.Use SQLiteDatabase
2.SQLiteDatabase and ReentrantLock
3.SQLiteDatabase wrapper
4.SQLiteDatabase Helper class
5.Using Database
6.SQLite based diary app
7.Create table, insert record, delete records, query table, remove table
8.Insert Data into database
9.Searchable Dictionary
10.Sqlite Annotations Helper