zoukankan      html  css  js  c++  java
  • JAVA 的data类型 long类型 生成星期几汇总

    **
    *
    * 时间的操作类
    *
    * */
    public class TimeUtil {

    /**
    * 返回系统时间
    *
    * @param void
    * @return 系统时间 long
    *
    * */
    public static long CurrentTime() {

    return System.currentTimeMillis();

    }

    /**
    * 返回年-月-日 hh:ff:ss
    *
    * @param time
    * long系统时间的long类型
    * @return String yyyy-MM-dd HH:mm:ss类型的时间类型
    * */
    public static String getFormatTime(long time) {

    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    Date date = new Date(time);

    String formatTime = format.format(date);

    return formatTime;

    }

    /**
    * 星期几
    *
    * @param data
    * Date 日期
    * @return 星期一到星期日
    *
    * */
    public static String getWeekOfDate(Date date) {
    String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
    if (w < 0)
    w = 0;

    return weekDays[w];
    }

    /**
    * 星期几
    *
    * @param time
    * long 系统时间的long类型
    * @return 星期一到星期日
    *
    * */
    public static String getWeekOfDate(long time) {

    Date date = new Date(time);
    String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
    if (w < 0)
    w = 0;

    return weekDays[w];
    }

    /**
    * 返回年-月-日 hh:ff:ss 星期几
    *
    * @param time
    * long系统时间
    * @return String 例如2013-05-26 19:39:26 星期日
    *
    * */

    public static String getDateAndWeek(long time) {

    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    Date date = new Date(time);

    String dateString = format.format(date);

    String dayString = getWeekOfDate(date);

    return dateString + " " + dayString;

    }

    }

  • 相关阅读:
    Swift -- Swfit 笔记
    web -- CSS 图片宽高不固定的垂直居中方法
    web -- Angularjs 笔记2
    web -- Angularjs 笔记
    web -- Angularjs 备忘录应用
    Swift -- swift 函数代码
    Swift -- 创建空数组和空字典
    Linux -- FresBSD的镜像文件说明
    Linux -- ubuntu下安装程序的三种方法
    Linux -- Ubuntu 命令2
  • 原文地址:https://www.cnblogs.com/qgzhan/p/3100319.html
Copyright © 2011-2022 走看看