Java Hour Calculate getWeeHours()

Here you can find the source of getWeeHours()

Description

get Wee Hours

License

Apache License

Declaration

public static Date getWeeHours() 

Method Source Code


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

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

public class Main {
    public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";

    public static Date getWeeHours() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        return calendar.getTime();
    }//from  ww w. j  av  a2s  . c om

    public static long getTime(String dateStr, String formate) {
        Date date;
        try {
            date = getDate(dateStr, formate);
            return date.getTime();
        } catch (ParseException e) {
            return -1;
        }
    }

    public static long getTime(String dateStr) {
        return getTime(dateStr, DEFAULT_FORMAT);
    }

    public static String getDate(Date date, String formate) {
        SimpleDateFormat sf = new SimpleDateFormat(formate);
        return sf.format(date);
    }

    public static Date getDate(String dateStr, String formate) throws ParseException {
        SimpleDateFormat sf = new SimpleDateFormat(formate);
        return sf.parse(dateStr);
    }
}

Related

  1. getExpiresDate(int hours)
  2. getTime(String dateStr, int hour, String timeZone)
  3. getTimestampFromDateHour2(String d)
  4. getTimeStringOfHourBefore(int hour)
  5. getTomorrowSixHours()
  6. hoursMinsSecsFromMs(long ms)
  7. isHourMinute(String str)
  8. isValidTime(int hour, int minute, boolean ampm)
  9. isValidTime(int hour, int minute, boolean ampm)