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

    }

    }

  • 相关阅读:
    Nhibernate多表查询解决办法
    Nhibernate compositeid class must override Equals()解决办法
    SQLSERVER2005安装说明
    IList转化为Dataset C#
    Named SQL queries
    把object转换成DataSet,进行数据绑定
    使用Lucene检索文档中的关键字
    使用代理为业务操作添加安全检测
    mongodb副本集架构搭建
    Java生成中文验证码
  • 原文地址:https://www.cnblogs.com/qgzhan/p/3100319.html
Copyright © 2020-2023  润新知