Java Week Day getLastWeekMs()

Here you can find the source of getLastWeekMs()

Description

get Last Week Ms

License

Open Source License

Declaration

public static long getLastWeekMs() 

Method Source Code

//package com.java2s;

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

public class Main {

    public static long getLastWeekMs() {
        return new Date().getTime() - 7 * 24 * 60 * 60 * 1000;
    }//  w w w  .ja v a2  s.c o m

    public static String getTime(Calendar c) {
        return getDate(c.getTime(), "HH:mm:ss");
    }

    public static String getDate() {
        return getDate(getCurDate(), "yyyy-MM-dd");
    }

    public static String getDate(Date date, String format) {

        String dtstr = "";
        if (date == null) {
            return dtstr;
        }

        if (format == null || "".equals(format.trim())) {
            format = "yyyy-MM-dd";
        }

        SimpleDateFormat sdf = new SimpleDateFormat(format);
        dtstr = sdf.format(date);
        return (dtstr == null ? "" : dtstr);

    }

    public static String getDate(Date date) {
        return getDate(date, "yyyy-MM-dd");
    }

    public static Date getDate(long time) {

        Calendar c = getCurCalendar();
        c.setTimeInMillis(time);

        return c.getTime();
    }

    public static Date getCurDate() {
        return getCurCalendar().getTime();
    }

    public static Calendar getCurCalendar() {
        return Calendar.getInstance();
    }
}

Related

  1. getLastDayOfWeek(int year, int month)
  2. getLastSundayBeforeThisWeek()
  3. getLastWeekday()
  4. getLastWeekDay(int weekDay)
  5. getLastWeekDay(int weekDay)
  6. getMon()
  7. getMonday(String date)
  8. getMonday(String date, int weekDay)
  9. getMondayAfter(Date date)