Android Day Get getHashByDay(String date)

Here you can find the source of getHashByDay(String date)

Description

get Hash By Day

License

Apache License

Declaration

public static int getHashByDay(String date) 

Method Source Code

//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import android.util.Log;

public class Main{
    private static final String TAG = "DateUtil";
    private static SimpleDateFormat formatter = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss");
    public static int getHashByDay(String date) {
        Date mDate = null;/*from  w  ww.  j a  va2s .  c om*/
        int dateInt = 0;
        Calendar cal = Calendar.getInstance();
        if (date != null && !date.isEmpty()) {
            try {
                mDate = DateTimeUtil.stringToDate(date);
            } catch (ParseException e) {
                Log.e(TAG, "Unparsable date");
            }
        }
        if (mDate != null) {
            cal.setTime(mDate);
            SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE",
                    Locale.US);
            SimpleDateFormat month_date = new SimpleDateFormat("MMMM");
            int dayOfMonth = cal.get(Calendar.DAY_OF_YEAR);
            int thisYear = cal.get(Calendar.YEAR);
            dateInt = thisYear * 1000;
            dateInt += dayOfMonth;

        }
        return dateInt;
    }
    public static Date stringToDate(String date) throws ParseException {
        formatter.setTimeZone(TimeZone.getTimeZone("gmt"));
        return (formatter.parse(date));
    }
}

Related

  1. getIndexDay(Date origin, int index)
  2. getDateOfLastSunday(Date d)
  3. getStartNextDay(Date d2)
  4. getNextDay(Date d2)
  5. getNextDateForDay(int calendarDay)
  6. getJulianDay(Calendar cal)
  7. getIntervalDays(String sd, String ed)
  8. isBirthday(Calendar cal)
  9. getBeforeDate(Date date, int days)