• 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;

    }

    }

  • 相关阅读:
    linux 配置ssh免密码登陆本机
    Java连接mysql数据库并插入中文数据显示乱码
    新浪微博热门评论爬虫采集
    新浪微博热门评论抽取规则
    【MySql】Java 批量插入数据库addBatch
    算法设计题4.3 等差数列
    PHP setcookie() 函数
    Linux下用于查看系统当前登录用户信息 w命令
    Ubuntu 登录锐捷 网卡被禁用 网口灯不亮解决
    将 VMware 最小化到系统托盘
  • 原文地址:https://www.cnblogs.com/qgzhan/p/3100319.html
Copyright © 2020-2023  润新知