Java Day of getLatest7Day()

Here you can find the source of getLatest7Day()

Description

get Latest Day

License

Apache License

Declaration

public static Map<String, Long[]> getLatest7Day() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Map;
import java.util.TreeMap;

public class Main {

    public static Map<String, Long[]> getLatest7Day() {
        String todayStr = "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
        todayStr = sdf.format(new Date(System.currentTimeMillis()));
        todayStr = todayStr + " 00:00:00";
        Date today = new Date();
        DateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Map<String, Long[]> data = new TreeMap<>();
        try {/*from w  ww .  ja  v a  2  s  . c o m*/
            today = sdf2.parse(todayStr);
            long todaybegin = today.getTime();
            data.put(new SimpleDateFormat("Mdd").format(todaybegin),
                    new Long[] { todaybegin / 1000, System.currentTimeMillis() / 1000 });
            for (int i = 1; i <= 6; i++) {
                data.put(new SimpleDateFormat("Mdd").format(new Date(todaybegin - 86400000 * i)), new Long[] {
                        (todaybegin - 86400000 * i) / 1000, (todaybegin - 86400000 * i + 86539000) / 1000 });
            }
        } catch (ParseException e) {
        }
        return data;
    }

    public static int getTime() {
        return (int) (System.currentTimeMillis() / 1000);
    }
}

Related

  1. getInsertDayDate(int days)
  2. getIntervalDate(String date, int intervalDays)
  3. getIntervalDays(Date fDate, Date oDate)
  4. getIntevalDays(String startDate, String endDate)
  5. getLateInTheDay(Date date)
  6. getNDayAfterCurrentDate(String dateStr, String dateFormat, int n)
  7. getOtherDayLastUpdateTimeFormat()
  8. getPaxBirthday()
  9. getPriorDay(int offset, String pattern)