package com.alamkanak.weekview.sample.apiclient;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.util.Log;

import com.alamkanak.weekview.WeekViewEvent;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by Alam Kanak on 1/3/16.
 */
public class Event {

    @Expose @SerializedName("name")
    private String mName;
    @Expose @SerializedName("dayOfMonth")
    private int mDayOfMonth;
    @Expose @SerializedName("startTime")
    private String mStartTime;
    @Expose @SerializedName("endTime")
    private String mEndTime;
    @Expose @SerializedName("color")
    private String mColor;

    public String getName() {
        return mName;
    }

    public void setName(String name) {
        this.mName = name;
    }

    public int getDayOfMonth() {
        return mDayOfMonth;
    }

    public void setDayOfMonth(int dayOfMonth) {
        this.mDayOfMonth = dayOfMonth;
    }

    public String getStartTime() {
        return mStartTime;
    }

    public void setStartTime(String startTime) {
        this.mStartTime = startTime;
    }

    public String getEndTime() {
        return mEndTime;
    }

    public void setEndTime(String endTime) {
        this.mEndTime = endTime;
    }

    public String getColor() {
        return mColor;
    }

    public void setColor(String color) {
        this.mColor = color;
    }

    @SuppressLint("SimpleDateFormat")
    public WeekViewEvent toWeekViewEvent(){

        // Parse time.
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
        Date start = new Date();
        Date end = new Date();
        try {
            start = sdf.parse(getStartTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        try {
            end = sdf.parse(getEndTime());
        } catch (ParseException e) {
            e.printStackTrace();
        }

        // Initialize start and end time.
        Calendar now = Calendar.getInstance();
        Calendar startTime = (Calendar) now.clone();
        startTime.setTimeInMillis(start.getTime());
        startTime.set(Calendar.YEAR, now.get(Calendar.YEAR));
        startTime.set(Calendar.MONTH, now.get(Calendar.MONTH));
        startTime.set(Calendar.DAY_OF_MONTH, getDayOfMonth());
        Calendar endTime = (Calendar) startTime.clone();
        endTime.setTimeInMillis(end.getTime());
        endTime.set(Calendar.YEAR, startTime.get(Calendar.YEAR));
        endTime.set(Calendar.MONTH, startTime.get(Calendar.MONTH));
        endTime.set(Calendar.DAY_OF_MONTH, startTime.get(Calendar.DAY_OF_MONTH));

        // Create an week view event.
        WeekViewEvent weekViewEvent = new WeekViewEvent();
        weekViewEvent.setName(getName());
        weekViewEvent.setStartTime(startTime);
        weekViewEvent.setEndTime(endTime);
        weekViewEvent.setColor(Color.parseColor(getColor()));

        Log.d("EVENT", "Start time: " + String.format("%d/%d/%d %d:%d", startTime.get(Calendar.DAY_OF_MONTH), startTime.get(Calendar.MONTH) + 1, startTime.get(Calendar.YEAR), startTime.get(Calendar.HOUR_OF_DAY), startTime.get(Calendar.MINUTE)));
        Log.d("EVENT", "End time: " + String.format("%d/%d/%d %d:%d", endTime.get(Calendar.DAY_OF_MONTH), endTime.get(Calendar.MONTH) + 1, endTime.get(Calendar.YEAR), endTime.get(Calendar.HOUR_OF_DAY), endTime.get(Calendar.MINUTE)));

        return weekViewEvent;
    }
}

@@ -117,33 +117,8 @@
 lor;
-%0Aimport android.util.Log;
 %0A%0Aim
@@ -3034,489 +3034,8 @@
 );%0A%0A
-        Log.d(%22EVENT%22, %22Start time: %22 + String.format(%22%25d/%25d/%25d %25d:%25d%22, startTime.get(Calendar.DAY_OF_MONTH), startTime.get(Calendar.MONTH) + 1, startTime.get(Calendar.YEAR), startTime.get(Calendar.HOUR_OF_DAY), startTime.get(Calendar.MINUTE)));%0A        Log.d(%22EVENT%22, %22End time: %22 + String.format(%22%25d/%25d/%25d %25d:%25d%22, endTime.get(Calendar.DAY_OF_MONTH), endTime.get(Calendar.MONTH) + 1, endTime.get(Calendar.YEAR), endTime.get(Calendar.HOUR_OF_DAY), endTime.get(Calendar.MINUTE)));%0A%0A
     

Remove logs