android-Date 与 DateFormat 与 Calendar
来源:互联网 发布:ubuntu 14 vim配置 编辑:程序博客网 时间:2024/05/23 01:22
public class SimpleDateFormat extends DateFormat {}
public abstract class DateFormat extends Format {}
格式化或解析日期和时间。
就是为了把date格式化到String.
把String变成date。
Date很多操作都过时了,需要Calendar实现拆分。需要Dateformat来显示。
详见 Date.class 源码 http://blog.csdn.net/ofreelander/article/details/45267501
* <p>Instances of this class are suitable for comparison, but little else.
* Use {@link java.text.DateFormat} to format a {@code Date} for display to a human.
* Use {@link Calendar} to break down a {@code Date} if you need to extract fields such
* as the current month or day of week, or to construct a {@code Date} from a broken-down
* time. That is: this class' deprecated display-related functionality is now provided
* by {@code DateFormat}, and this class' deprecated computational functionality is
* now provided by {@code Calendar}. Both of these other classes (and their subclasses)
* allow you to interpret a {@code Date} in a given time zone.
*
* <p>Note that, surprisingly, instances of this class are mutable.
*/
这个类的实例适用于比较,也仅限于此。为了给人展示时间,用java.text.DateFormat来格式化一个Date实例。如果你需要获取某个域,例如当前月份和日期,使用Calendar来划分Date。也可以从一个分解的时间构造一个Date。
也就是说,这个类与显示相关的过时的功能现在由DateFormat来实现,这个类与计算相关的过时的功能由Calendar来实现。Calendar和DateFormat这两个类(包括子类)允许你解析Date在给定的时区里。
Calendar.class 源码
**
* {@code Calendar} is an abstract base class for converting between a
* {@code Date} object and a set of integer fields such as
* {@code YEAR}, {@code MONTH}, {@code DAY},
* {@code HOUR}, and so on. (A {@code Date} object represents a
* specific instant in time with millisecond precision. See {@link Date} for
* information about the {@code Date} class.)
*Calendar是一个抽象基类,用来转换Date对象和一系列整形数。例如year,month 等等。一个Date对象代表一个特定的毫秒精度的时刻。
* <p>
* Subclasses of {@code Calendar} interpret a {@code Date}
* according to the rules of a specific calendar system.
*根据calendar系统的规则,Calendar的子类解析Date对象。
* <p>
* Like other locale-sensitive classes, {@code Calendar} provides a class
* method, {@code getInstance}, for getting a default instance of
* this class for general use. {@code Calendar}'s {@code getInstance} method
* returns a calendar whose locale is based on system settings and whose time fields
* have been initialized with the current date and time: <blockquote>
*像其他的地域敏感的类,Calendar提供了一个方法getInstance()来得到一个类的实例,它的区域设置是基于系统设置,时间域已经被初始化为当前的日期和时间。
* <pre>Calendar rightNow = Calendar.getInstance()</pre>
*DateFormat.class 源码
/**
* Utility class for producing strings with formatted date/time.
*格式化日期时间到字符串的工具类。
* <p>Most callers should avoid supplying their own format strings to this
* class' {@code format} methods and rely on the correctly localized ones
* supplied by the system. This class' factory methods return
* appropriately-localized {@link java.text.DateFormat} instances, suitable
* for both formatting and parsing dates. For the canonical documentation
* of format strings, see {@link java.text.SimpleDateFormat}.
*调用者应该避免提供自己的字符串给format()方法。应该使用系统提供的本地化的一个。
这个类的工厂方法返回适当的本地化的Dateformat实例,来实现格式化和解析dates。
* <p>In cases where the system does not provide a suitable pattern,
* this class offers the {@link #getBestDateTimePattern} method.
* 在系统没有提供合适的格式化模板时,类提供了getBestDateTimePattern()方法。
- android-Date 与 DateFormat 与 Calendar
- 6.8 Date 与Calendar DateFormat类
- Date类,Calendar类与DateFormat类
- Date、DateFormat、Calendar
- Java-Date, Calendar, DateFormat
- Java - Date - Calendar - DateFormat
- java中的Date与DateFormat
- java常用类库续1(日期操作类Date、Calendar、DateFormat、SimpleDateFormat、Math与Random类)
- java常用类库续1(日期操作类Date、Calendar、DateFormat、SimpleDateFormat、Math与Random类)
- Date、Calendar与DateFormat(子类SimpleDateFormat)_思维导图总结
- Calendar 与 Date 转换
- Calendar与Date类
- Calendar与Date
- Date与Calendar类
- calendar与Date
- 浅析Date与Calendar
- Programming: java Date, Calendar, DateFormat
- Date,DateFormat,Calendar类用法
- 【Linux】Ubuntu下C语言访问MySQL数据库入门
- Web_PHP_DedeCMS_登陆后台卡死(假死)解决方法之一;
- Linux命令:free
- Python实现基本数据结构---栈操作
- mavan 安装配置
- android-Date 与 DateFormat 与 Calendar
- 读《从0到1》有感
- 设计模式之解析器
- 索引结构
- 设计模式 笔记 责任链模式 chain of responsibility
- ANT(3) 编译 打包 移动 重命名
- iOS应用安全Part41:使用LLDB调试APP
- UOJ#14【UER#1】DZY Loves Graph
- 黑马程序员——java基础(其它常用对象)