get Current Week Day End Time - Android java.util

Android examples for java.util:Day

Description

get Current Week Day End Time

Demo Code


//package com.java2s;

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

public class Main {

    private final static SimpleDateFormat shortSdf = new SimpleDateFormat(
            "yyyy-MM-dd");
    private final static SimpleDateFormat longSdf = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm:ss");

    public static Date getCurrentWeekDayEndTime() {
        Calendar c = Calendar.getInstance();
        try {//from w w  w.  j  av a2 s  .  c  o  m
            int weekday = c.get(Calendar.DAY_OF_WEEK);
            c.add(Calendar.DATE, 8 - weekday);
            c.setTime(longSdf.parse(shortSdf.format(c.getTime())
                    + " 23:59:59"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return c.getTime();
    }
}

Related Tutorials