Search code examples
androidcaldroid

how to change multi dates color in caldroid


Code block has been formatted for better visibility

guys i'm trying to change color of different dates

void changeEventDateColor(){
    DatabaseHandler databaseHandler=new DatabaseHandler(this);
    List<Contact> contacts=databaseHandler.getAllContacts();
    //String[] date=new String[contacts.size()];

    String date="11/02/2016T09:27:37Z";

    //for(Contact cn: contacts){

    //date=cn.get_date();

    String[] d=date.split("/");
    Log.d("date   ============", d[0]+"/"+d[1]+"/"+d[2]);

    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy'T'HH:mm:ss'Z'");
    try {
        Date parsedDate = formatter.parse(date);
        Log.d("date   ============", parsedDate+"");
        Log.d("date   ============", formatter.format(parsedDate));
        caldroidFragment.setBackgroundResourceForDate(R.color.blue,parsedDate);
        caldroidFragment.refreshView();
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    //}
}

anyone please tell whats wrong.


Solution

  • Use SimpleDateFormat

    SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy");
    

    instead of

     SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy'T'HH:mm:ss'Z'");