本文整理了Java中java.text.SimpleDateFormat
类的一些代码示例,展示了SimpleDateFormat
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SimpleDateFormat
类的具体详情如下:
包路径:java.text.SimpleDateFormat
类名称:SimpleDateFormat
[英]Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and parsing turns a String into a Date.
You can supply a Unicode UTS #35 pattern describing what strings are produced/accepted, but almost all callers should use DateFormat#getDateInstance, DateFormat#getDateTimeInstance, or DateFormat#getTimeInstance to get a ready-made instance suitable for the user's locale. In cases where the system does not provide a suitable pattern, see android.text.format.DateFormat#getBestDateTimePattern which lets you specify the elements you'd like in a pattern and get back a pattern suitable for any given locale.
The main reason you'd create an instance this class directly is because you need to format/parse a specific machine-readable format, in which case you almost certainly want to explicitly ask for Locale#US to ensure that you get ASCII digits (rather than, say, Arabic digits). (See "Be wary of the default locale".) The most useful non-localized pattern is "yyyy-MM-dd HH:mm:ss.SSSZ", which corresponds to the ISO 8601 international standard date format.
To specify the time format, use a time pattern string. In this string, any character from 'A' to 'Z' or 'a' to 'z' is treated specially. All other characters are passed through verbatim. The interpretation of each of the ASCII letters is given in the table below. ASCII letters not appearing in the table are reserved for future use, and it is an error to attempt to use them.
The number of consecutive copies (the "count") of a pattern character further influences the format, as shown in the table. For fields of kind "number", the count is the minimum number of digits; shorter values are zero-padded to the given width and longer values overflow it.
SymbolMeaningKindExampleDday in year(Number)189Eday of week(Text)E/ EE/ EEE:Tue, EEEE:Tuesday, EEEEE:TFday of week in month(Number)2 (2nd Wed in July)Gera designator(Text)ADHhour in day (0-23)(Number)0Khour in am/pm (0-11)(Number)0Lstand-alone month(Text)L:1 LL:01 LLL:Jan LLLL:January LLLLL:JMmonth in year(Text)M:1 MM:01 MMM:Jan MMMM:January MMMMM:JSfractional seconds(Number)978Wweek in month(Number)2Ztime zone (RFC 822)(Time Zone)Z/ ZZ/ ZZZ:-0800 ZZZZ:GMT-08:00 ZZZZZ:-08:00aam/pm marker(Text)PMcstand-alone day of week(Text)c/ cc/ ccc:Tue, cccc:Tuesday, ccccc:Tdday in month(Number)10hhour in am/pm (1-12)(Number)12khour in day (1-24)(Number)24mminute in hour(Number)30ssecond in minute(Number)55wweek in year(Number)27yyear(Number)yy:10 y/ yyy/ yyyy:2010ztime zone(Time Zone)z/ zz/ zzz:PST zzzz:Pacific Standard Time'escape for text(Delimiter)'Date=':Date=''single quote(Literal)'o''clock':o'clock
Fractional seconds are handled specially: they're zero-padded on the right.
The two pattern characters L and c are ICU-compatible extensions, not available in the RI or in Android before Android 2.3 (Gingerbread, API level 9). These extensions are necessary for correct localization in languages such as Russian that make a grammatical distinction between, say, the word "June" in the sentence "June" and in the sentence "June 10th"; the former is the stand-alone form, the latter the regular form (because the usual case is to format a complete date). The relationship between Eand c is equivalent, but for weekday names.
Five-count patterns (such as "MMMMM") used for the shortest non-numeric representation of a field were introduced in Android 4.3 (Jelly Bean MR2, API level 18).
When two numeric fields are directly adjacent with no intervening delimiter characters, they constitute a run of adjacent numeric fields. Such runs are parsed specially. For example, the format "HHmmss" parses the input text "123456" to 12:34:56, parses the input text "12345" to 1:23:45, and fails to parse "1234". In other words, the leftmost field of the run is flexible, while the others keep a fixed width. If the parse fails anywhere in the run, then the leftmost field is shortened by one character, and the entire run is parsed again. This is repeated until either the parse succeeds or the leftmost field is one character in length. If the parse still fails at that point, the parse of the run fails.
See #set2DigitYearStart for more about handling two-digit years.
If you're formatting for human use, you should use an instance returned from DateFormat as described above. This code:
DateFormat[] formats = new DateFormat[] {
DateFormat.getDateInstance(),
DateFormat.getDateTimeInstance(),
DateFormat.getTimeInstance(),
};
for (DateFormat df : formats) {
System.out.println(df.format(new Date(0)));
}
Produces this output when run on an en_US device in the America/Los_Angeles time zone:
Dec 31, 1969
Dec 31, 1969 4:00:00 PM
4:00:00 PM
And will produce similarly appropriate localized human-readable output on any user's system.
If you're formatting for machine use, consider this code:
String[] formats = new String[] {
"yyyy-MM-dd",
"yyyy-MM-dd HH:mm",
"yyyy-MM-dd HH:mmZ",
"yyyy-MM-dd HH:mm:ss.SSSZ",
"yyyy-MM-dd'T'HH:mm:ss.SSSZ",
};
for (String format : formats) {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
}
Which produces this output when run in the America/Los_Angeles time zone:
yyyy-MM-dd 1969-12-31
yyyy-MM-dd 1970-01-01
yyyy-MM-dd HH:mm 1969-12-31 16:00
yyyy-MM-dd HH:mm 1970-01-01 00:00
yyyy-MM-dd HH:mmZ 1969-12-31 16:00-0800
yyyy-MM-dd HH:mmZ 1970-01-01 00:00+0000
yyyy-MM-dd HH:mm:ss.SSSZ 1969-12-31 16:00:00.000-0800
yyyy-MM-dd HH:mm:ss.SSSZ 1970-01-01 00:00:00.000+0000
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1969-12-31T16:00:00.000-0800
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1970-01-01T00:00:00.000+0000
As this example shows, each SimpleDateFormat instance has a TimeZone. This is because it's called upon to format instances of Date, which represents an absolute time in UTC. That is, Date does not carry time zone information. By default, SimpleDateFormat will use the system's default time zone. This is appropriate for human-readable output (for which, see the previous sample instead), but generally inappropriate for machine-readable output, where ambiguity is a problem. Note that in this example, the output that included a time but no time zone cannot be parsed back into the original Date. For this reason it is almost always necessary and desirable to include the timezone in the output. It may also be desirable to set the formatter's time zone to UTC (to ease comparison, or to make logs more readable, for example). It is often best to avoid formatting completely when writing dates/times in machine-readable form. Simply sending the "Unix time" as a longor as the string corresponding to the long is cheaper and unambiguous, and can be formatted any way the recipient deems appropriate.
SimpleDateFormat is not thread-safe. Users should create a separate instance for each thread.
[中]以区域设置敏感的方式格式化和分析日期。格式化将日期转换为字符串,解析将字符串转换为日期。
#####时间模式语法
您可以提供一个Unicode{$0$}模式来描述生成/接受的字符串,但是几乎所有调用方都应该使用DateFormat#getDateInstance、DateFormat#getDateTimeInstance或DateFormat#getTimeInstance来获得适合用户区域设置的现成实例。如果系统没有提供合适的模式,请参阅android。文本总体安排DateFormat#getBestDateTimePattern,用于指定模式中所需的元素,并返回适合任何给定区域设置的模式。
您直接创建此类实例的主要原因是,您需要格式化/解析特定的机器可读格式,在这种情况下,您几乎肯定希望显式地请求Locale#US以确保获得ASCII数字(而不是阿拉伯语数字)。(见“{$1$}”。)最有用的非本地化模式是“yyyy-MM-dd HH:MM:ss.SSSZ”,它对应于ISO 8601国际标准日期格式。
要指定时间格式,请使用时间模式字符串。在此字符串中,从“A”到“Z”或从“A”到“Z”的任何字符都会被特殊处理。所有其他字符都会逐字传递。下表给出了每个ASCII字母的解释。表中未出现的ASCII字母保留供将来使用,尝试使用它们是错误的。
模式字符的连续拷贝数(“计数”)进一步影响格式,如表所示。对于“数字”类型的字段,计数是最小位数;较短的值被零填充到给定的宽度,较长的值溢出该宽度。
SYMBOL表示年份的日期(数字)189周的日期(文本)E/EE/EEE:Tue,EEE:周二,Eeee:TFday of week in month(数字)2(7月第二个星期三)Gera指示符(文本)ADH Hour in day(0-23)(数字)0Khour in am/pm(0-11)(数字)0Ls and Lone month(数字)0Ll:1Ll:Jan LLL:Jan LLL:Jan LLL:JM month in year(文本)M:1mm:01 MMM:Jan MMM:Jan MMM:Jan MMM:MMM:J分秒(数字)978Wweek in month(数字)2Z时区(RFC 822)(时区)Z/ZZ/ZZZ:-0800 ZZZZ:GMT-08:00 ZZZZZ:-08:00aam/pm标记(文本)PMCST和单独的星期几(文本)c/cc/ccc:Tue,cccc:周二,ccccc:Tdday in month(数字)10hhour in am/pm(1-12)(数字)12khour in day(1-24)(数字)24mminute in hour(数字)30s second in minute(数字)55wweek in year(数字)27yyear(数字)yy:10y/yyyy/yyyyyy:2010ztime zone(时区)z/zz/zz:PST zzz:PST zzz:太平洋标准时间“文本转义(分隔符)”日期=“:日期=”:日期=““单引号(文字)”00:00
小数秒是专门处理的:它们在右边是零填充的。
两个模式字符L和c是ICU兼容的扩展,在Android 2.3(Gingerbread,API级别9)之前的RI或Android中不可用。这些扩展对于俄语等语言的正确本地化是必要的,这些语言在语法上区分了“June”一句中的“June”一词和“June 10th”一句中的“June”;前者是独立表单,后者是常规表单(因为通常情况下是格式化完整的日期)。EAN和c之间的关系是等效的,但对于工作日名称而言是等效的。
Android 4.3(Jelly Bean MR2,API级别18)中引入了用于字段最短非数字表示的五种计数模式(如“MMMMM”)。
当两个数字字段直接相邻且没有中间分隔符时,它们构成一系列相邻的数字字段。这样的运行是专门解析的。例如,格式“HHmmss”将输入文本“123456”解析为12:34:56,将输入文本“12345”解析为1:23:45,但未能解析“1234”。换句话说,梯段最左侧的字段是灵活的,而其他字段保持固定宽度。如果在运行中的任何地方解析失败,则最左边的字段将缩短一个字符,并再次解析整个运行。重复此操作,直到解析成功或最左边的字段长度为一个字符。如果此时解析仍然失败,则运行的解析将失败。
有关处理两位数年份的更多信息,请参见#set2DigitYearStart。
#####示例代码
如果您正在格式化供人使用,则应使用如上所述从DateFormat返回的实例。此代码:
DateFormat[] formats = new DateFormat[] {
DateFormat.getDateInstance(),
DateFormat.getDateTimeInstance(),
DateFormat.getTimeInstance(),
};
for (DateFormat df : formats) {
System.out.println(df.format(new Date(0)));
}
在美国/洛杉矶时区的en_US设备上运行时生成此输出:
Dec 31, 1969
Dec 31, 1969 4:00:00 PM
4:00:00 PM
并将在任何用户的系统上生成类似的适当本地化的人类可读输出。
如果您正在格式化机器使用,请考虑此代码:
String[] formats = new String[] {
"yyyy-MM-dd",
"yyyy-MM-dd HH:mm",
"yyyy-MM-dd HH:mmZ",
"yyyy-MM-dd HH:mm:ss.SSSZ",
"yyyy-MM-dd'T'HH:mm:ss.SSSZ",
};
for (String format : formats) {
SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.format("%30s %s\n", format, sdf.format(new Date(0)));
}
在美国/洛杉矶时区运行时产生此输出:
yyyy-MM-dd 1969-12-31
yyyy-MM-dd 1970-01-01
yyyy-MM-dd HH:mm 1969-12-31 16:00
yyyy-MM-dd HH:mm 1970-01-01 00:00
yyyy-MM-dd HH:mmZ 1969-12-31 16:00-0800
yyyy-MM-dd HH:mmZ 1970-01-01 00:00+0000
yyyy-MM-dd HH:mm:ss.SSSZ 1969-12-31 16:00:00.000-0800
yyyy-MM-dd HH:mm:ss.SSSZ 1970-01-01 00:00:00.000+0000
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1969-12-31T16:00:00.000-0800
yyyy-MM-dd'T'HH:mm:ss.SSSZ 1970-01-01T00:00:00.000+0000
如本例所示,每个SimpleDataFormat实例都有一个时区。这是因为它被调用来格式化日期实例,日期代表UTC中的绝对时间。也就是说,日期不包含时区信息。默认情况下,SimpleDataFormat将使用系统的默认时区。这适用于人类可读的输出(参见前面的示例),但通常不适用于机器可读的输出,因为机器可读的输出存在歧义。请注意,在本例中,包含时间但没有时区的输出无法解析回原始日期。因此,在输出中包含时区几乎总是必要和可取的。可能还需要将格式化程序的时区设置为UTC(例如,为了便于比较或使日志更可读)。在以机器可读的形式编写日期/时间时,通常最好避免完全格式化。简单地将“Unix时间”作为long或与long对应的字符串发送,既便宜又不含糊,而且可以按照接收者认为合适的任何方式进行格式化。
#####同步
SimpleDataFormat不是线程安全的。用户应该为每个线程创建一个单独的实例。
canonical example by Tabnine
public boolean isDateExpired(String input, Date expiration) throws ParseException {
DateFormat dateFormat = new SimpleDateFormat ("dd/MM/yyyy");
Date date = dateFormat.parse(input);
return date.after(expiration);
}
代码示例来源:origin: stackoverflow.com
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
//Local time zone
SimpleDateFormat dateFormatLocal = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss");
//Time in GMT
return dateFormatLocal.parse( dateFormatGmt.format(new Date()) );
代码示例来源:origin: org.testng/testng
static String timeAsGmt() {
SimpleDateFormat sdf = new SimpleDateFormat();
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
sdf.applyPattern("dd MMM yyyy HH:mm:ss z");
return sdf.format(Calendar.getInstance().getTime());
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof String) {
try {
return new SimpleDateFormat(DATE_FORMAT).parse((String) jv);
} catch (ParseException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
if (jv instanceof Number) {
return new Date(((Number) jv).longValue());
}
return (Date) null;
}
};
代码示例来源:origin: spring-projects/spring-framework
private DateFormat newDateFormat() {
SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.US);
dateFormat.setTimeZone(GMT);
return dateFormat;
}
代码示例来源:origin: alibaba/druid
public static String toString(java.util.Date date) {
if (date == null) {
return null;
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return format.format(date);
}
代码示例来源:origin: spring-projects/spring-framework
private long parseDateHeader(String name, String value) {
for (String dateFormat : DATE_FORMATS) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat, Locale.US);
simpleDateFormat.setTimeZone(GMT);
try {
return simpleDateFormat.parse(value).getTime();
}
catch (ParseException ex) {
// ignore
}
}
throw new IllegalArgumentException("Cannot parse date value '" + value + "' for '" + name + "' header");
}
代码示例来源:origin: stackoverflow.com
// Create an instance of SimpleDateFormat used for formatting
// the string representation of date (month/day/year)
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
// Get the date today using Calendar object.
Date today = Calendar.getInstance().getTime();
// Using DateFormat format method we can create a string
// representation of a date with the defined format.
String reportDate = df.format(today);
// Print what date is today!
System.out.println("Report Date: " + reportDate);
代码示例来源:origin: weibocom/motan
private void printStartInfo() {
Date currentDate = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.SECOND, runTime);
Date finishDate = calendar.getTime();
StringBuilder startInfo = new StringBuilder(dateFormat.format(currentDate));
startInfo.append(" ready to start client benchmark");
startInfo.append(", concurrent num is ").append(concurrents);
startInfo.append(", the benchmark will end at ").append(dateFormat.format(finishDate));
System.out.println(startInfo.toString());
}
代码示例来源:origin: blynkkk/blynk-server
/**
* Sets the Date and Cache headers for the HTTP Response
*
* @param response
* HTTP response
* @param fileToCache
* file to extract content type
*/
private static void setDateAndCacheHeaders(io.netty.handler.codec.http.HttpResponse response, File fileToCache) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
// Date header
Calendar time = new GregorianCalendar();
response.headers().set(DATE, dateFormatter.format(time.getTime()));
// Add cache headers
time.add(Calendar.SECOND, HTTP_CACHE_SECONDS);
response.headers()
.set(EXPIRES, dateFormatter.format(time.getTime()))
.set(CACHE_CONTROL, "private, max-age=" + HTTP_CACHE_SECONDS)
.set(LAST_MODIFIED, dateFormatter.format(new Date(fileToCache.lastModified())));
}
代码示例来源:origin: north2016/T-MVP
public static List<String> getOldWeekDays() {
final Calendar c = Calendar.getInstance();
String[] months = new String[8];
for (int i = 0; i < 8; i++) {
months[i] = new SimpleDateFormat("MM.dd").format(new Date(c
.getTimeInMillis()));
c.add(Calendar.DAY_OF_MONTH, -1);
}
return Arrays.asList(months);
}
代码示例来源:origin: stackoverflow.com
Calendar c = Calendar.getInstance();
c.setTime(new Date(yourmilliseconds));
c.set(Calendar.MILLISECOND, 0);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm.ss.SSS'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(sdf.format(c.getTime()));
代码示例来源:origin: stackoverflow.com
Date now = new Date(); // java.util.Date, NOT java.sql.Date or java.sql.Timestamp!
String format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.ENGLISH).format(now);
String format2 = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH).format(now);
String format3 = new SimpleDateFormat("yyyyMMddHHmmss", Locale.ENGLISH).format(now);
System.out.println(format1);
System.out.println(format2);
System.out.println(format3);
代码示例来源:origin: apache/incubator-dubbo
private String getTimeoutMessage(boolean scan) {
long nowTimestamp = System.currentTimeMillis();
return (sent > 0 ? "Waiting server-side response timeout" : "Sending request timeout in client-side")
+ (scan ? " by scan timer" : "") + ". start time: "
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date(start))) + ", end time: "
+ (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date())) + ","
+ (sent > 0 ? " client elapsed: " + (sent - start)
+ " ms, server elapsed: " + (nowTimestamp - sent)
: " elapsed: " + (nowTimestamp - start)) + " ms, timeout: "
+ timeout + " ms, request: " + request + ", channel: " + channel.getLocalAddress()
+ " -> " + channel.getRemoteAddress();
}
}
代码示例来源:origin: stackoverflow.com
UTC = TimeZone.getTimeZone("UTC");
TimeZone.setDefault(UTC);
final Calendar c = new GregorianCalendar(UTC);
c.set(1, 0, 1, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
BEGINNING_OF_TIME = c.getTime();
c.setTime(new Date(Long.MAX_VALUE));
END_OF_TIME = c.getTime();
final SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_24H_FULL_FORMAT);
sdf.setTimeZone(UTC);
System.out.println("sdf.format(BEGINNING_OF_TIME) = " + sdf.format(BEGINNING_OF_TIME));
System.out.println("sdf.format(END_OF_TIME) = " + sdf.format(END_OF_TIME));
System.out.println("sdf.format(new Date()) = " + sdf.format(new Date()));
System.out.println("sdf.parse(\"2015-04-28T14:23:38.521Z\") = " + sdf.parse("2015-04-28T14:23:38.521Z"));
System.out.println("sdf.parse(\"0001-01-01T00:00:00.000Z\") = " + sdf.parse("0001-01-01T00:00:00.000Z"));
代码示例来源:origin: apache/rocketmq
public String getCurTime() {
String fromTimeZone = "GMT+8";
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
format.setTimeZone(TimeZone.getTimeZone(fromTimeZone));
String chinaDate = format.format(date);
return chinaDate;
}
代码示例来源:origin: blynkkk/blynk-server
/**
* Sets the Date header for the HTTP response
*
* @param response
* HTTP response
*/
private static void setDateHeader(FullHttpResponse response) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));
Calendar time = new GregorianCalendar();
response.headers().set(DATE, dateFormatter.format(time.getTime()));
}
代码示例来源:origin: stackoverflow.com
final DateFormat format = new SimpleDateFormat("E. M/d");
final String dateStr = "Thu. 03/01";
final Date date = format.parse(dateStr);
GregorianCalendar gregory = new GregorianCalendar();
gregory.setTime(date);
XMLGregorianCalendar calendar = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(
gregory);
代码示例来源:origin: elastic/elasticsearch-hadoop
@Test
public void testCalendar() {
Date d = new Date(0);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
assertThat(jdkTypeToJson(cal), containsString(new SimpleDateFormat("yyyy-MM-dd").format(d)));
}
代码示例来源:origin: kiegroup/jbpm
protected List<TimePeriod> parseHolidays() {
String holidaysString = businessCalendarConfiguration.getProperty(HOLIDAYS);
List<TimePeriod> holidays = new ArrayList<TimePeriod>();
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
if (holidaysString != null) {
String[] hPeriods = holidaysString.split(",");
SimpleDateFormat sdf = new SimpleDateFormat(businessCalendarConfiguration.getProperty(HOLIDAY_DATE_FORMAT, "yyyy-MM-dd"));
for (String hPeriod : hPeriods) {
boolean addNextYearHolidays = false;
Calendar tmpFrom = new GregorianCalendar();
if (timezone != null) {
tmpFrom.setTimeZone(TimeZone.getTimeZone(timezone));
tmpFrom.setTime(sdf.parse(fromTo[0]));
tmpTo.setTime(sdf.parse(fromTo[1]));
tmpFrom.setTime(sdf.parse(fromTo[0]));
tmpTo.setTime(sdf.parse(fromTo[1]));
c.setTime(sdf.parse(fromTo[0]));
holidays.add(new TimePeriod(sdf.parse(fromTo[0]), c.getTime()));
tmp.setTime(sdf.parse(fromTo[0]));
内容来源于网络,如有侵权,请联系作者删除!