Java Week Calculate getWeekAbscissa(Class cls)

Here you can find the source of getWeekAbscissa(Class cls)

Description

get Week Abscissa

License

Open Source License

Declaration

public static <T> Map<Date, T> getWeekAbscissa(Class<T> cls) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {

    public static <T> Map<Date, T> getWeekAbscissa(Class<T> cls) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MINUTE, 0);
        Date end = calendar.getTime();
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        Date start = calendar.getTime();
        Map<Date, T> week = new TreeMap<>();
        while (start.getTime() <= end.getTime()) {
            start = new Date(start.getTime() / 1000 * 1000);
            if (Integer.class.equals(cls)) {
                week.put(start, (T) (Integer) 0);
            }/*  www .j a v a2s  .co m*/
            if (Float.class.equals(cls)) {
                week.put(start, (T) (Float) 0.0f);
            }
            if (Double.class.equals(cls)) {
                week.put(start, (T) (Double) 0.0);
            }
            calendar.add(Calendar.DAY_OF_YEAR, 1);
            start = calendar.getTime();
        }
        return week;
    }
}

Related

  1. getCurrentWeekNum(Date startDate, Date endDate)
  2. getCurrWeek()
  3. getEndOfWeek(Calendar cal)
  4. getSeqWeek()
  5. getWeek(Date date)
  6. getWeekNumberFromDate(Date date)
  7. getWeekOfDate(Date date)
  8. getWeekOfYear(Date date, Locale locale)
  9. getWeeksAddCount(int repType, int repIndex)