date

对Linux系统中的时钟和时间的探讨

回眸只為那壹抹淺笑 提交于 2020-04-06 20:16:39
概要 1)介绍Linux系统中时钟的基本概念 2)探讨hwclock命令的工作方式。 3)系统启动过程中Linux系统对系统时钟和硬件时钟的同步。 主要术语和背景知识 UTC: Coordinated Universal Time, 一种是件标准,用以规范世界各地的时间。 Time Zone: 时区,表示方式是:UTC-xx:xx, UTC+xx:xx。比如中国的时区表示是:UTC+08:00. 其他一些相关术语,比如CST,DST等,我们并不需要关心。 典型Linux 对时钟和时间的管理 一个典型的Linux系统主要有两种时钟:系统时钟(System Clock)和硬件时钟(Hardware Clock)。 硬件时钟独立运行于操作系统之外,有自己的电源供给,即使当系统关机时,它也依然在跑。Hardware Clock有时也叫BIOS Clock, CMOS Clock, RTC 等。但是只有hardware clock这个词汇不容易引起误解。 系统时钟就是由操作系统维护的一个时钟。在Linux系统中,是由kernel维护,由timer的中断进行驱动的一个时钟(因为它是由计时器的中断驱动的,所以可以认为是一个软件时钟)。 有两个时钟,就需要有同步。这个同步功能由hwclock来实现。在此仅作简要介绍,详情请查询手册(man hwclock).

PostgreSQL 自定义自动类型转换(CAST) integer_to_text

自闭症网瘾萝莉.ら 提交于 2020-04-06 17:34:12
PostgreSQL是一个强类型数据库,因此你输入的变量、常量是什么类型,是强绑定的,例如 在调用操作符时,需要通过操作符边上的数据类型,选择对应的操作符。 在调用函数时,需要根据输入的类型,选择对应的函数。 如果类型不匹配,就会报操作符不存在,或者函数不存在的错误。 postgres=# select '1' + '1'; ERROR: operator is not unique: unknown + unknown LINE 1: select '1' + '1'; ^ HINT: Could not choose a best candidate operator. You might need to add explicit type casts. 那么使用起来是不是很不方便呢? PostgreSQL开放了类型转换的接口,同时也内置了很多的自动类型转换。来简化操作。 查看目前已有的类型转换: postgres= # \dC+ List of casts Source type | Target type | Function | Implicit? | Description -----------------------------+-----------------------------+--------------------+---------------+--

hive内部表、外部表、分区

房东的猫 提交于 2020-04-06 12:41:44
hive内部表、外部表、分区 内部表(managed table) 默认创建的是内部表(managed table),存储位置在 hive.metastore.warehouse.dir 设置,默认位置是 /user/hive/warehouse 。 导入数据的时候是将文件剪切(移动)到指定位置,即原有路径下文件不再存在 删除表的时候,数据和元数据都将被删除 默认创建的就是内部表 create table xxx (xx xxx) 外部表(external table) 外部表文件可以在外部系统上,只要有访问权限就可以 外部表导入文件时不移动文件,仅仅是添加一个metadata 删除外部表时原数据不会被删除 分辨外部表内部表可以使用 DESCRIBE FORMATTED table_name 命令查看 创建外部表命令添加一个external即可,即 create external table xxx (xxx) 外部表指向的数据发生变化的时候会自动更新,不用特殊处理 表分区(Partitioned table) 有些时候数据是有组织的,比方按日期/类型等分类,而查询数据的时候也经常只关心部分数据,比方说我只想查2017年8月8号,此时可以创建分区 使用 partioned by (xxx) 来创建表的分区,比方说 create table table_name ( id int,

你还在用 Date?建议使用 LocalDateTime 了!

我的未来我决定 提交于 2020-04-06 12:27:50
在项目开发过程中经常遇到时间处理,但是你真的用对了吗,理解阿里巴巴开发手册中禁用static修饰SimpleDateFormat吗? 通过阅读本篇文章你将了解到: 为什么需要LocalDate、LocalTime、LocalDateTime【java8新提供的类】; java8新的时间API的使用方式,包括创建、格式化、解析、计算、修改。 为什么需要LocalDate、LocalTime、LocalDateTime 1.Date如果不格式化,打印出的日期可读性差 Tue Sep 10 09:34:04 CST 2019 2.使用SimpleDateFormat对时间进行格式化,但SimpleDateFormat是线程不安全的SimpleDateFormat的format方法最终调用代码: private StringBuffer format(Date date, StringBuffer toAppendTo, FieldDelegate delegate) { // Convert input date to time field list calendar.setTime(date); boolean useDateFormatSymbols = useDateFormatSymbols(); for (int i = 0; i < compiledPattern

phoenix 报错:type org.apache.phoenix.schema.types.PhoenixArray is not supported

可紊 提交于 2020-04-06 10:24:34
今天用phoenix报如下错误: 主要原因:   hbase的表中某字段类型是array,phoenix目前不支持此类型 解决方法: 复制替换phoenix包的cursor文件 # Copyright 2015 Lukas Lalinsky # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific

java基础--日期--练习集锦

孤街浪徒 提交于 2020-04-06 08:33:05
题目1 --日期 借助随机数,创建一个从1995.1.1 00:00:00 到 1995.12.31 23:59:59 之间的随机日期 package date; import java.util.Date; public class TestDate { public static void main(String[] args) { long second = 1000; long minute = 60*second; long hour = minute * 60; long day = hour*24; long year = day * 365; long year1995Start = (1995-1970) * year; long leapDay = (1995-1970)/4*day; //每隔4年有一个润日 year1995Start+=leapDay; long eightHour = hour*8; //8个小时的毫秒数,因为从0毫秒对应的是1970.1.1 08:00:00 year1995Start-=eightHour; Date dStart = new Date(year1995Start); System.out.println("1995年第一天:"+dStart); long year1995End = year1995Start +

MYSQL 中常用日期时间函数使用

ぐ巨炮叔叔 提交于 2020-04-06 07:14:31
MySQL Date 函数 下面的表格列出了 MySQL 中最重要的内建日期函数: 函数 描述 NOW() 返回当前的日期和时间 CURDATE() 返回当前的日期 CURTIME() 返回当前的时间 DATE() 提取日期或日期/时间表达式的日期部分 EXTRACT() 返回日期/时间按的单独部分 DATE_ADD() 给日期添加指定的时间间隔 DATE_SUB() 从日期减去指定的时间间隔 DATEDIFF() 返回两个日期之间的天数 DATE_FORMAT() 用不同的格式显示日期/时间 SELECT NOW ();/*2013-10-25 15:24:12*/ SELECT UNIX_TIMESTAMP ();/*1382685853*/ SELECT from_unixtime (137123321); /* 1974-05-07 09:48:41 */ SELECT from_unixtime (xtimestamp) as aa FROM TEST; SELECT UNIX_TIMESTAMP ('2013-09-09 12:12:12'); /*1378699932*/ select adddate ('2013-09-09 12:12:12',1);/*2013-09-10 12:12:12*/ DECLARE @orderdate int; #set

MySql日期与时间函数

浪子不回头ぞ 提交于 2020-04-06 07:00:47
mysqldump -uroot -haliyuncs.com -p2018 xb_data event_record -w " date ( event_date ) <= date_sub (curdate(),interval 7 day)" 按event_date时间字段备份七天之前的数据 select DATE_FORMAT(date_sub(current_date(), interval 1 day), '%Y-%m-%d') -- 2018-05-29(昨天) select DATE_FORMAT(date_sub(current_date(), interval 31 day), '%Y-%m-%d 00:00:00' ) -- 2018-04-29 00:00:00 select DATE_SUB(current_date, INTERVAL 35 DAY) -- 2018-04-25 -- MySQL日期时间处理函数 -- 当前日期:2017-05-12(突然发现今天512,是不是会拉防空警报) SELECT NOW() FROM DUAL;-- 当前日期时间:2017-05-12 11:41:47 -- 在MySQL里也存在和Oracle里类似的dual虚拟表:官方声明纯粹是为了满足select ... from...这一习惯问题

convert nanoseconds since 1904 to a valid java date

烈酒焚心 提交于 2020-04-06 05:15:01
问题 I have a number representing the number of nanoseconds since 12:00 a.m., January 1, 1904, universal time. I wish to instantiate a java.util.Date object representing that date. How should I proceed? 回答1: You first need to convert your number representing nanoseconds to milliseconds . Then for the given date string, get the total number of milliseconds since the unix time Epoch , and then add the number earlier converted to milliseconds to it. Here's the working code: String target = "1904/01

convert nanoseconds since 1904 to a valid java date

南笙酒味 提交于 2020-04-06 05:07:26
问题 I have a number representing the number of nanoseconds since 12:00 a.m., January 1, 1904, universal time. I wish to instantiate a java.util.Date object representing that date. How should I proceed? 回答1: You first need to convert your number representing nanoseconds to milliseconds . Then for the given date string, get the total number of milliseconds since the unix time Epoch , and then add the number earlier converted to milliseconds to it. Here's the working code: String target = "1904/01