Ten Amazing Java Applications

Java is such a great language and platform for any kind of application. It is open, fast, powerful, runs on any platform, and there are more jobs for Java than any other programming language. After reading more FUD and Java bashing from Ruby land I thought it would be fun to put together a list of truly amazing uses of Java that covers a wide spectrum.


 


10 – Sun SPOT


The Sun SPOT Device is a small, wireless, battery powered experimental platform. It is programmed almost entirely in Java to allow regular programmers to create projects that used to require specialized embedded system development skills. The hardware platform includes a range of built-in sensors as well as the ability to easily interface to external devices. The SPOT Development Kit contains two complete, free-range Sun SPOTs (with processor, radio, sensor board and battery) and one basestation Sun SPOT (with processor and radio). Also included are all the software development tools and cables required to start developing applications for your Sun SPOT.


 


 


9 – Project Looking Glass


Project Looking Glass is an open source development project based on and evolved from Sun Microsystems’ advanced technology project. It supports running unmodified existing applications in a 3D space, as well as APIs for 3D window manager and application development. At the moment, existing application integration is supported for Solaris x86 and Linux platforms. The library for 3D application development is available for Linux, Solaris and Windows.


 


 


8 – Flying Saucer & Mozilla Rhino


Flying Saucer is 100% Java XHTML+CSS renderer, including support for table pagination, margin boxes, running elements, named pages, and more. It is CSS 2.1 compliant (currently working on CSS 3 compliance), can be embedded into your Swing applications, and uses the open source LGPL license. This is a very impressive library! Equally impressive is Mozilla Rhino. Rhino is an open-source implementation of JavaScript written entirely in Java. It is typically embedded into Java applications to provide scripting to end users. Imagine combining Flying Saucer, Applets/JavaFX Script support, Rhino, and the hugely improved “Consumer JRE”!


 


 


7 – UltraMixer


UltraMixer is a DJ mixing software which enables you to mix digital music in various formats such as MP3, WMA, AAC, OGG, WAV or CDs in real time. All you need is a sound card. The DJ’s turntables are replaced by two digital SoundPlayers, the “vinyls” are available within seconds through the integrated FileArchive. There are three versions of UltraMixer available: the Free Edition and the Basic Edition for private users and the Professional Edition for high demands and commercial use. It can interface with a number of hardware controllers so you don’t have to use a mouse.


 


 


6 – Blu-ray BD-J


The Blu-ray Disc Association (BDA) selected Java technology to be used as the platform for their advanced interactive application specification. Java technology was selected because:



  • Java technology has proven to be a technically sound solution in the mobile domain and in interactive television (MHP/OCAP)
  • Java technology has proven cross-platform technology support in embedded devices
  • Java technology provides an open-ended platform for content development with secure network support

I have seen a live demo of BD-J at JavaOne and was very impressed. Blu-ray seems to be winning the battle. It might finally be time to pick up a Blu-ray player.


 


 


5 – JavaFX Script & JavaFX Mobile


JavaFX Script is a compiled declarative scripting language that will soon be built into Java that enables Java developers and graphics designers to create rich user interfaces comparable to Adobe Flash. Recently key-frame animation support was added. The graphical designer tool being developed will be an Adobe Illustrator plugin. Rich Internet Applications built using JavaFX Script will run in the browser as an applet. An effort of cosmic proportions has been done to the Java Runtime Environment to improve startup time and responsiveness of applets.


 


JavaFX Mobile is a complete mobile operating and application environment built around Java and Linux open source technologies. JavaFX Mobile includes support for Java ME applications and other standard Java APIs to enable a broad range of new and existing Java applications. I think JavaFX Mobile brings a nearly complete Java SE environment to mobile devices (minus some things such as Corba, JMX, etc). Sun is a bit late in the game, but I think this will really pick up. I know I would prefer a full Java RIA over Adobe Flex.


 


4 – NASA World Wind


World Wind lets you zoom from satellite altitude into any place on Earth. Leveraging Landsat satellite imagery and Shuttle Radar Topography Mission data, World Wind lets you experience Earth terrain in visually rich 3D, just as if you were really there. It is very much like Google Earth, but written 100% in Java. There is an SDK for embedding it into your Java Swing applications.


 


 


3 – Team Jefferson’s Tommy Junior bot


Tommy Jr. is based on a Scion xB vehicle platform. The team’s secret weapon is the patent pending MAX software platform from Perrone Robotics. MAX represents the DNA and core robotics operating system that enables the rapid drop-in of commercially available and affordable sensors, hardware, and actuators. MAX is based 100% on Sun Microsystems’ Java technology. Tommy Junior’s micro-controllers and single low-cost standard car PC run the MAX robotics platform atop of standard, micro, and Java Real Time System (Java RTS) profiles.


The team’s after-market drop-in approach enables any vehicle whatsoever to be made fully autonomous within a short period of time. Tommy Junior’s cost in parts has been a mere $50,000 which includes the automotive platform itself. After actuators and hardware were dropped in, Tommy Junior was up and running in just 24 hours with Tommy senior navigation and obstacle avoidance capabilities. While Tommy Junior and Tommy senior share the same MAX DNA, Tommy Junior has since surpassed his father’s wits with new rules of behavior rapidly evolved for city driving.


 


2 – ThinkFree


ThinkFree is the compatible alternative to Microsoft Office. It includes ThinkFree Write (word processing), ThinkFree Calc (spreadsheet), and ThinkFree Show (presentation) applications that let you create, edit, and update your documents. The ThinkFree interface is designed to look, feel, and behaves like Microsoft Office, eliminating the learning curve. Because ThinkFree application use the same formats as Word, Excel, and PowerPoint, you can rest assured that your documents will look the same in ThinkFree as they do in Microsoft Office-no matter what editing features you are using. It can also save as PDF.


 


ThinkFree is written in Java, so it runs on Windows, Mac and Linux. There is a free online edition with 1 GB of storage, collaboration tools, publishing to blogs, web pages or ThinkFree Docs. I think it loads using Java Web Start? You can also host it on your own server, or run it as a desktop application.


 


1 – JPC


JPC is a pure Java emulation of an x86 PC with fully virtual peripherals. It runs anywhere you have a JVM, whether x86, RISC, mobile phone, set-top box, possibly even your refrigerator! All this, with the bulletproof security and stability of Java technology.


 


JPC creates a virtual computer upon which you can install your favorite operating system in a safe, flexible and powerful way. It aims to give you complete control over your favorite PC software’s execution environment, whatever your real hardware or operating system, and JPC’s multi-layered security makes it the safest solution for running the most dangerous software in quarantine – ideal for archiving viruses, hosting honey pots, and protecting your machine from malicious or unstable software.


It was hard to choose only ten application when there are so many cool looking scientific applications, 3D games, IDEs, languages that run on the JVM, etc. It’s incredible what people are doing with Java these days.


Also, there has been talk about aging mission critical real-time control systems transitioning to Java Real Time System (RTS) such as Nuclear Power Plants, Aircraft Control, Submarine Control, Factory Automation, Airport Aviation Flight Control, Energy and Power Systems Supply, Telecommunication Satellite and so forth. I saw a demonstration of the world’s fastest moving robot arm being controlled by a Java RTS application at JavaOne 2007. Very cool stuff.

The Best Java Tools You Never Knew Existed


I was at an awesome presentation at JavaOne of the long tail of Java tools that not many people have come across, which I had to share. So, in no particular order, and with my own emotive comments:



  • Apache Abdera – work easily with Atom feeds. See also Rome.

  • Antlr – this parser generator can look daunting, but it’s pretty easy once you get your head around it. Can be used to parse things like complex URLs where regexps are not up to the job.

  • ApacheDS – Java LDAP and Kerberos server, very easy to embed and great for testing your directory code. Now under the Apache Directory project which has heaps of other good stuff.

  • ASM – small, efficient bytecode manipulation

  • CGLIB – built on ASM, it works at a higher level and makes the former look like Assembler by comparison. Only downside is that it’s not well documented

  • JEXL – easily embeddable expression language, compares with OGNL

  • DisplayTag – JSP taglib for table formatting and exporting

  • EHCache – easy in-memory caching for everyone. Used this, it’s awesome.

  • Janino – someone took the time to write an embeddable Java compiler! It lets you use Java like a scripting language, eg. allow your users to type Java expressions directly into your GUIs.

  • Jar Jar Links – allows you to overcome namespace/package clashes between different versions of libraries used by your product by repackaging them. Similar to the Minijar Maven plugin that approaches the problem slightly differently by removing unused classes. Can be used to resolve dependency issues (classpath hell).

  • jDBI – substitute for JDBC that doesn’t suck when used directly

  • Jetty – web server/servlet container. Lightweight, yet lightning fast. Great for embedding, drives Grails.

  • Joda Time – date time library that kicks butt over java.util.Calendar. Intuitive (January is month 1!), easy to use and complete – everything that the java.util classes aren’t. Can be used alongside Date and Calendar. Chances are that the JSR based on this will become a part of Java 7, but why wait when you can use it now!

  • JSON-lib – best Java JSON library out there. Has good documentation. See also Jaxen.

  • Commons Math – everything from linear algebra to statistics

  • Mock Javamail – mock test infrastructure for Javamail code. See also Dumpster, Smartster.

  • Not-Yet-Commons-SSL – Nice, easy to use Java wrapper over OpenSSL. Encryption for the masses!

  • Selenium – test your web app interaction! HTML/JS, browser-based test environment – JUnit starts playing with windows :).

  • Selenium IDE – the “IDE” part may be overstating things, but this Firefox plugin generates the basis of your test code for you. See also Canoo Webtest.

  • Selenium Maven plugin – self explanatory

  • Sitemesh – like Tiles, but non-intrusive and heaps better. It hasn’t been updated for ages because it Just Works.

  • Smack – Java Jabber client

  • XStream – objects -> XML -> objects translation. I can’t recommend this one enough, awesome one to have in the toolbox.

  • StringTemplate – like Velocity, but better.

  • Ivy – this Ant plugin means that dependency management is not just for Maven any more. I worked on a big project that used this and it worked a treat.

  • Subetha – a mailing list manager and embeddable mail server. See also James.

  • Scriptella – extract, transform and load (ETL) tool for Java.

Feel free to add any gems that you have come across in the comments!


Resin 3.2.1 破解文件 crack keygen

resin3.2.1 的破解文件,仅供学习所用,不得用于商业用途.

把附件里的文件覆盖${resin_home}\lib里的pro.jar 即可
没用用户的可以用test/test 下载
如果你的版本不是是resin3.2.1,如果覆盖不能用时,可以试一下,把附件里的pro.jar里的 \com\caucho\license 目录覆盖你的pro里相应目录

linux下使用nload查看网卡实时流量

linux下使用nload查看网卡实时流量


nload是一个网络流量统计工具,当前版本为0.7.2。
下载地址:http://sourceforge.net/project/showfiles.php?group_id=35865


使用yum 安装也可以。


yum install nload


使用源码方式安装到/usr/local/nload,将/usr/local/nload/bin目录加入/etc/profile。


重新登陆ssh后,直接输入nload即可查看网卡的当前流量情况。
nload eth0 — 查看名叫eth0网卡的流量


可查看当前、平均、最小、最大、总共等的流量情况,单位为bit,详细的使用说明请参见:
http://www.debuntu.org/2006/07/14/74-nload-a-network-traffic-analyser


resin-pro-3.1.8破解下载

resin-pro-3.1.8在11月18号已经正式发布,这次有点慢了,主要是不知道这个版本已经发布了,以后有新版本发布时,请及时通知作者( dingl.com (At) gmail.com )。

破解下载 :

Resin Change Log

我会及时破解Resin的最新版本!

resin-pro-3.1.8.zip
resin-pro-3.1.8.tar.gz

原文:http://www.dingl.com/blog/archives/49

Linux/Ubuntu tar命令详解使用格式和方法

格式: tar 选项 文件目录列表
功能: 对文件目录进行打包备份
选项:
-c 建立新的归档文件
-r 向归档文件末尾追加文件
-x 从归档文件中解出文件
-O 将文件解开到标准输出
-v 处理过程中输出相关信息
-f 对普通文件操作
-z 调用gzip来压缩归档文件,与-x联用时调用gzip完成解压缩
-Z 调用compress来压缩归档文件,与-x联用时调用compress完成解压缩



例如:


1.将当前目录下所有.txt文件打包并压缩归档到文件this.tar.gz,我们可以使用


tar czvf this.tar.gz ./*.txt


2.将当前目录下的this.tar.gz中的文件解压到当前目录我们可以使用


tar xzvf this.tar.gz ./


 


应对20号微软正版验证,Office2003通过正版验证的方法


本文给大家介绍了通过Office2003正版验证的方法,其实还是一个方法……


1.开始-运行-regedit
找到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Registration\{90110804-6000-11D3-8CFE-0150048383C9}

删除
ProductID
DigitalProductID


2.运行office,出现安装程序,输入FTYBP-J2B4K-K7JHY-3JG2K-MT9VM(或换个其它序列号)

3.去微软官网看是否通过正版验证:www.microsoft.com/Genuine/diag/default.aspx?displaylang=zh-cn

利用临时表,加快存储过程的执行速度。

利用临时表,加快存储过程的执行速度。


背景:
  一个博客网站访问流量表,每天有大约100万条数据插入,记录每个博客及网站的访问情况。表结构:
mysql> show fields from blog_track;
+—————-+————–+——+—–+———+—————-+
| Field          | Type         | Null | Key | Default | Extra          |
+—————-+————–+——+—–+———+—————-+
| track_id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| track_ip       | char(15)     | YES  |     | NULL    |                |
| track_date     | datetime     | NO   | MUL |         |                |
| track_page     | varchar(256) | YES  |     | NULL    |                |
| track_refferer | varchar(500) | YES  |     | NULL    |                |
| member_id      | int(11)      | NO   | MUL | 0       |                |
| visiter_id     | int(11)      | NO   |     | 0       |                |
| track_type     | tinyint(4)   | NO   | MUL | 0       |                |
+—————-+————–+——+—–+———+—————-+



每隔2小时就会利用存储过程对这个表进行统计,包括统计当天的IP及PV。


CREATE DEFINER=`root`@`%` PROCEDURE `prc_anaylise_track`()
BEGIN


declare time_now datetime;
DROP TABLE IF EXISTS tmp_tables;
CREATE TEMPORARY TABLE tmp_tables (
blog_id int NOT NULL,
count int NOT NULL,
ip char(15) null
) engine = HEAP;
set time_now = now();
insert into tmp_tables(count,blog_id,ip) select count(*) as count,member_id as blog_id,track_ip as ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′) and member_id>0 group by track_ip,member_id;
update blog_info set blog_info.today_ip = (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);
delete from tmp_tables;
select concat(‘count today ip count need time : ‘,(unix_timestamp(now()) – unix_timestamp(time_now))) as neetTime;
END


使用了一个临时表保存统计结果,执行时间超过15秒。



下面是使用了两个临时表的代码:


CREATE DEFINER=`root`@`%` PROCEDURE `prc_anaylise_user`()
BEGIN


declare time_now datetime;
DROP TABLE IF EXISTS tmp_tables_full;
CREATE TEMPORARY TABLE tmp_tables_full (
blog_id int not null,
count int not null default 0,
ip char(15) null,
index blog_id(blog_id)
)engine = HEAP;


DROP TABLE IF EXISTS tmp_tables;
CREATE TEMPORARY TABLE tmp_tables (
blog_id int NOT NULL,
count int NOT NULL,
ip char(15) null,
index blog_id(blog_id)
) engine = HEAP;


set time_now = now();
insert into tmp_tables_full(blog_id,ip) select member_id,track_ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′) and member_id>0;
insert into tmp_tables(count,blog_id,ip) select count(*) as count,blog_id,ip  from tmp_tables_full group by blog_id,ip;
update blog_info set blog_info.today_ip = (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);
delete from tmp_tables_full;
delete from tmp_tables;
select concat(‘count today ip count need time : ‘,(unix_timestamp(now()) – unix_timestamp(time_now))) as neetTime;
END


第一个临时表存放今天的访问记录,第一个临时表存放统计结果。这样做的目的是避免统计时间过长,锁表时间过长,导致网站访问不正常。执行时间为2秒。



进一步优化:
定义一个临时变量,
declare p_updatetime datetime;
建立一个tmpupdatetable表,保存上一次执行的时间;
select updatetime into p_updatetime from tmpupdatetable;
把最后执行的时间回到where条件里:
insert into tmp_tables_full(blog_id,ip) select member_id,track_ip  from blog_track where track_type=0 and track_date>=date_format(now(),’%Y-%m-%d 00:00:00′)  and track_date>=p_updatetime and member_id>0;
更新数据时的代码:
update blog_info set blog_info.today_ip =blog_info.today_ip+ (select count(*) as count from tmp_tables where blog_info.member_id=tmp_tables.blog_id);



经过样的修改,执行时间变了120ms左右。已经符合要求了,如果没有达到这个效果的话,请检查一个blog_track表的索引。


DreamCoder for MySQL 4.4.2 crack 破解 Patch KEYGEN

DreamCoder for MySQL。


  本人一直在使用navicat作为Mysql client,不过navicat写存储过程不太方便,每次写存储过程时都切换到mysql administrator,终于给我发现了一个好东东DreamCoder for MySQL,看了看官网的介绍,抱着一试的态度下载了企业版,感觉非常好,特别在写存储过程,很好很强大。哈哈。。分享给大家。

  终于找到破解版了,Thanks god~

下载:

企业版 http://www.sqldeveloper.net/download/installer_dreamcoder_for_mysql_enterprise.exe
专业版 http://www.sqldeveloper.net/download/installer_dreamcoder_for_mysql_professional.exe
标准版 http://www.sqldeveloper.net/download/installer_dreamcoder_for_mysql_standard.exe
免费版 http://www.sqldeveloper.net/download/installer_dreamcoder_for_mysql_free.exe

 

 


 

 

Mysql日期和时间函数不求人

对于每个类型拥有的值范围以及并且指定日期何时间值的有效格式的描述见7.3.6 日期和时间类型。 

这里是一个使用日期函数的例子。下面的查询选择了所有记录,其date_col的值是在最后30天以内: 

mysql> SELECT something FROM table 
WHERE TO_DAYS(NOW()) – TO_DAYS(date_col) <= 30; 

DAYOFWEEK(date) 
返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。这些索引值对应于ODBC标准。 
mysql> select DAYOFWEEK(‘1998-02-03’); 
-> 3 

WEEKDAY(date) 
返回date的星期索引(0=星期一,1=星期二, ……6= 星期天)。 
mysql> select WEEKDAY(‘1997-10-04 22:23:00’); 
-> 5 
mysql> select WEEKDAY(‘1997-11-05’); 
-> 2 

DAYOFMONTH(date) 
返回date的月份中日期,在1到31范围内。 
mysql> select DAYOFMONTH(‘1998-02-03’); 
-> 3 

DAYOFYEAR(date) 
返回date在一年中的日数, 在1到366范围内。 
mysql> select DAYOFYEAR(‘1998-02-03’); 
-> 34 

MONTH(date) 
返回date的月份,范围1到12。 
mysql> select MONTH(‘1998-02-03’); 
-> 2 

DAYNAME(date) 
返回date的星期名字。 
mysql> select DAYNAME(“1998-02-05”); 
-> ‘Thursday’ 

MONTHNAME(date) 
返回date的月份名字。 
mysql> select MONTHNAME(“1998-02-05”); 
-> ‘February’ 

QUARTER(date) 
返回date一年中的季度,范围1到4。 
mysql> select QUARTER(’98-04-01′); 
-> 2 

WEEK(date) 
  
WEEK(date,first) 
对于星期天是一周的第一天的地方,有一个单个参数,返回date的周数,范围在0到52。2个参数形式WEEK()允许
你指定星期是否开始于星期天或星期一。如果第二个参数是0,星期从星期天开始,如果第二个参数是1,
从星期一开始。 
mysql> select WEEK(‘1998-02-20’); 
-> 7 
mysql> select WEEK(‘1998-02-20’,0); 
-> 7 
mysql> select WEEK(‘1998-02-20’,1); 
-> 8 

YEAR(date) 
返回date的年份,范围在1000到9999。 
mysql> select YEAR(’98-02-03′); 
-> 1998 

HOUR(time) 
返回time的小时,范围是0到23。 
mysql> select HOUR(’10:05:03′); 
-> 10 

MINUTE(time) 
返回time的分钟,范围是0到59。 
mysql> select MINUTE(’98-02-03 10:05:03′); 
-> 5 

SECOND(time) 
回来time的秒数,范围是0到59。 
mysql> select SECOND(’10:05:03′); 
-> 3 

PERIOD_ADD(P,N) 
增加N个月到阶段P(以格式YYMM或YYYYMM)。以格式YYYYMM返回值。注意阶段参数P不是日期值。 
mysql> select PERIOD_ADD(9801,2); 
-> 199803 

PERIOD_DIFF(P1,P2) 
返回在时期P1和P2之间月数,P1和P2应该以格式YYMM或YYYYMM。注意,时期参数P1和P2不是日期值。 
mysql> select PERIOD_DIFF(9802,199703); 
-> 11 

DATE_ADD(date,INTERVAL expr type) 
  
DATE_SUB(date,INTERVAL expr type) 
  
ADDDATE(date,INTERVAL expr type) 
  
SUBDATE(date,INTERVAL expr type) 
这些功能执行日期运算。对于MySQL 3.22,他们是新的。ADDDATE()和SUBDATE()是DATE_ADD()和DATE_SUB()的同义词。
在MySQL 3.23中,你可以使用+和-而不是DATE_ADD()和DATE_SUB()。(见例子)date是一个指定开始日期的
DATETIME或DATE值,expr是指定加到开始日期或从开始日期减去的间隔值一个表达式,expr是一个字符串;它可以以
一个“-”开始表示负间隔。type是一个关键词,指明表达式应该如何被解释。EXTRACT(type FROM date)函数从日期
中返回“type”间隔。下表显示了type和expr参数怎样被关联: type值 含义 期望的expr格式 
SECOND 秒 SECONDS 
MINUTE 分钟 MINUTES 
HOUR 时间 HOURS 
DAY 天 DAYS 
MONTH 月 MONTHS 
YEAR 年 YEARS 
MINUTE_SECOND 分钟和秒 “MINUTES:SECONDS” 
HOUR_MINUTE 小时和分钟 “HOURS:MINUTES” 
DAY_HOUR 天和小时 “DAYS HOURS” 
YEAR_MONTH 年和月 “YEARS-MONTHS” 
HOUR_SECOND 小时, 分钟, “HOURS:MINUTES:SECONDS” 
DAY_MINUTE 天, 小时, 分钟 “DAYS HOURS:MINUTES” 
DAY_SECOND 天, 小时, 分钟, 秒 “DAYS HOURS:MINUTES:SECONDS” 

MySQL在expr格式中允许任何标点分隔符。表示显示的是建议的分隔符。如果date参数是一个DATE值并且你的计算仅仅
包含YEAR、MONTH和DAY部分(即,没有时间部分),结果是一个DATE值。否则结果是一个DATETIME值。 

mysql> SELECT “1997-12-31 23:59:59” + INTERVAL 1 SECOND; 
-> 1998-01-01 00:00:00 
mysql> SELECT INTERVAL 1 DAY + “1997-12-31”; 
-> 1998-01-01 
mysql> SELECT “1998-01-01” – INTERVAL 1 SECOND; 
-> 1997-12-31 23:59:59 
mysql> SELECT DATE_ADD(“1997-12-31 23:59:59”, 
INTERVAL 1 SECOND); 
-> 1998-01-01 00:00:00 
mysql> SELECT DATE_ADD(“1997-12-31 23:59:59”, 
INTERVAL 1 DAY); 
-> 1998-01-01 23:59:59 
mysql> SELECT DATE_ADD(“1997-12-31 23:59:59”, 
INTERVAL “1:1” MINUTE_SECOND); 
-> 1998-01-01 00:01:00 
mysql> SELECT DATE_SUB(“1998-01-01 00:00:00”, 
INTERVAL “1 1:1:1” DAY_SECOND); 
-> 1997-12-30 22:58:59 
mysql> SELECT DATE_ADD(“1998-01-01 00:00:00”, 
INTERVAL “-1 10” DAY_HOUR); 
-> 1997-12-30 14:00:00 
mysql> SELECT DATE_SUB(“1998-01-02”, INTERVAL 31 DAY); 
-> 1997-12-02 
mysql> SELECT EXTRACT(YEAR FROM “1999-07-02”); 
-> 1999 
mysql> SELECT EXTRACT(YEAR_MONTH FROM “1999-07-02 01:02:03”); 
-> 199907 
mysql> SELECT EXTRACT(DAY_MINUTE FROM “1999-07-02 01:02:03”); 
-> 20102 

如果你指定太短的间隔值(不包括type关键词期望的间隔部分),MySQL假设你省掉了间隔值的最左面部分。例如,
如果你指定一个type是DAY_SECOND,值expr被希望有天、小时、分钟和秒部分。如果你象”1:10″这样指定值,
MySQL假设日子和小时部分是丢失的并且值代表分钟和秒。换句话说,”1:10″ DAY_SECOND以它等价于”1:10″ MINUTE_SECOND
的方式解释,这对那MySQL解释TIME值表示经过的时间而非作为一天的时间的方式有二义性。如果你使用确实不正确的日期,
结果是NULL。如果你增加MONTH、YEAR_MONTH或YEAR并且结果日期大于新月份的最大值天数,日子在新月用最大的天调整。 

mysql> select DATE_ADD(‘1998-01-30’, Interval 1 month); 
-> 1998-02-28 

注意,从前面的例子中词INTERVAL和type关键词不是区分大小写的。 
TO_DAYS(date) 
给出一个日期date,返回一个天数(从0年的天数)。 
mysql> select TO_DAYS(950501); 
-> 728779 
mysql> select TO_DAYS(‘1997-10-07’); 
-> 729669 

TO_DAYS()不打算用于使用格列高里历(1582)出现前的值。 

FROM_DAYS(N) 
给出一个天数N,返回一个DATE值。 
mysql> select FROM_DAYS(729669); 
-> ‘1997-10-07’ 

TO_DAYS()不打算用于使用格列高里历(1582)出现前的值。 

DATE_FORMAT(date,format) 
根据format字符串格式化date值。下列修饰符可以被用在format字符串中: %M 月名字(January……December) 
%W 星期名字(Sunday……Saturday) 
%D 有英语前缀的月份的日期(1st, 2nd, 3rd, 等等。) 
%Y 年, 数字, 4 位 
%y 年, 数字, 2 位 
%a 缩写的星期名字(Sun……Sat) 
%d 月份中的天数, 数字(00……31) 
%e 月份中的天数, 数字(0……31) 
%m 月, 数字(01……12) 
%c 月, 数字(1……12) 
%b 缩写的月份名字(Jan……Dec) 
%j 一年中的天数(001……366) 
%H 小时(00……23) 
%k 小时(0……23) 
%h 小时(01……12) 
%I 小时(01……12) 
%l 小时(1……12) 
%i 分钟, 数字(00……59) 
%r 时间,12 小时(hh:mm:ss [AP]M) 
%T 时间,24 小时(hh:mm:ss) 
%S 秒(00……59) 
%s 秒(00……59) 
%p AM或PM 
%w 一个星期中的天数(0=Sunday ……6=Saturday ) 
%U 星期(0……52), 这里星期天是星期的第一天 
%u 星期(0……52), 这里星期一是星期的第一天 
%% 一个文字“%”。 

所有的其他字符不做解释被复制到结果中。 

mysql> select DATE_FORMAT(‘1997-10-04 22:23:00’, ‘%W %M %Y’); 
-> ‘Saturday October 1997’ 
mysql> select DATE_FORMAT(‘1997-10-04 22:23:00’, ‘%H:%i:%s’); 
-> ’22:23:00′ 
mysql> select DATE_FORMAT(‘1997-10-04 22:23:00’, 
‘%D %y %a %d %m %b %j’); 
-> ‘4th 97 Sat 04 10 Oct 277’ 
mysql> select DATE_FORMAT(‘1997-10-04 22:23:00’, 
‘%H %k %I %r %T %S %w’); 
-> ’22 22 10 10:23:00 PM 22:23:00 00 6′ 
MySQL3.23中,在格式修饰符字符前需要%。在MySQL更早的版本中,%是可选的。 

TIME_FORMAT(time,format) 
这象上面的DATE_FORMAT()函数一样使用,但是format字符串只能包含处理小时、分钟和秒的那些格式修饰符。
其他修饰符产生一个NULL值或0。 
CURDATE() 
  
CURRENT_DATE 
以’YYYY-MM-DD’或YYYYMMDD格式返回今天日期值,取决于函数是在一个字符串还是数字上下文被使用。 
mysql> select CURDATE(); 
-> ‘1997-12-15’ 
mysql> select CURDATE() + 0; 
-> 19971215 

CURTIME() 
  
CURRENT_TIME 
以’HH:MM:SS’或HHMMSS格式返回当前时间值,取决于函数是在一个字符串还是在数字的上下文被使用。 
mysql> select CURTIME(); 
-> ’23:50:26′ 
mysql> select CURTIME() + 0; 
-> 235026 

NOW() 
  
SYSDATE() 
  
CURRENT_TIMESTAMP 
以’YYYY-MM-DD HH:MM:SS’或YYYYMMDDHHMMSS格式返回当前的日期和时间,取决于函数是在一个字符串还是在数字的
上下文被使用。 
mysql> select NOW(); 
-> ‘1997-12-15 23:50:26’ 
mysql> select NOW() + 0; 
-> 19971215235026 

UNIX_TIMESTAMP() 
  
UNIX_TIMESTAMP(date) 
如果没有参数调用,返回一个Unix时间戳记(从’1970-01-01 00:00:00’GMT开始的秒数)。如果UNIX_TIMESTAMP()用一
个date参数被调用,它返回从’1970-01-01 00:00:00′ GMT开始的秒数值。date可以是一个DATE字符串、一个DATETIME
字符串、一个TIMESTAMP或以YYMMDD或YYYYMMDD格式的本地时间的一个数字。 
mysql> select UNIX_TIMESTAMP(); 
-> 882226357 
mysql> select UNIX_TIMESTAMP(‘1997-10-04 22:23:00’); 
-> 875996580 

当UNIX_TIMESTAMP被用于一个TIMESTAMP列,函数将直接接受值,没有隐含的“string-to-unix-timestamp”变换。 

FROM_UNIXTIME(unix_timestamp) 
以’YYYY-MM-DD HH:MM:SS’或YYYYMMDDHHMMSS格式返回unix_timestamp参数所表示的值,取决于函数是在一个字符串
还是或数字上下文中被使用。 
mysql> select FROM_UNIXTIME(875996580); 
-> ‘1997-10-04 22:23:00’ 
mysql> select FROM_UNIXTIME(875996580) + 0; 
-> 19971004222300 

FROM_UNIXTIME(unix_timestamp,format) 
返回表示 Unix 时间标记的一个字符串,根据format字符串格式化。format可以包含与DATE_FORMAT()函数列出的条
目同样的修饰符。 
mysql> select FROM_UNIXTIME(UNIX_TIMESTAMP(), 
‘%Y %D %M %h:%i:%s %x’); 
-> ‘1997 23rd December 03:43:30 x’ 

SEC_TO_TIME(seconds) 
返回seconds参数,变换成小时、分钟和秒,值以’HH:MM:SS’或HHMMSS格式化,取决于函数是在一个字符串还是在数字
上下文中被使用。 
mysql> select SEC_TO_TIME(2378); 
-> ’00:39:38′ 
mysql> select SEC_TO_TIME(2378) + 0; 
-> 3938 

TIME_TO_SEC(time) 
返回time参数,转换成秒。 
mysql> select TIME_TO_SEC(’22:23:00′); 
-> 80580 
mysql> select TIME_TO_SEC(’00:39:38′); 
-> 2378