l**s 发帖数: 28 | 1 thanks.
DateFormat should handle DST, it has a TimeZone with it.
I think the problem will be either DateFormat.format() returns wrong string
or DateFormat.parse() returns wrong date, It might be a Java bug,since
it only happens in Australia TimeZones. |
|
m******t 发帖数: 2416 | 2
I'm not sure DateFormat handles daylight saving times.
You might want to look into Calendar, and more specifically,
GregorianCalendar. The javadoc of GregorianCalendar has some interesting
discussion and example on how to handle the daylight saving time offset. |
|
c*******e 发帖数: 290 | 3 对,因为那个 date 是个 local variable, 每次都重新创建。所以,他那个例子完全
不适合,根本就用不上 ThreadLocal, 他那个 PerThreadFormatter 完全是多余的. 贴
出他的完整例子:
/**
*
* @author
*/
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
/*
* Thread safe format method because every thread will use its own
DateFormat
*/
public static S... 阅读全帖 |
|
F****n 发帖数: 3271 | 4 IMO, those RDBMS people constantly cannot understand the difference between
a date and a dateformat. Those people always try to legitimate their
implementation by spending several pages talking about Date Format. In fact
for date / time storage you only need a integer / long, and the complexity
of DateFormat can always be encapsulated in the JDBC driver (or other DB
access API). |
|
|
b****i 发帖数: 805 | 6 价格不错,就是交通不太方便。多谢了。
sid=7pAHg._fmotgV76g.12&sarea=&sname=&sstate=&scountry=&sradius=&slat=&slo
n=&schain=&exp=&scity=&sort=&type=&map=&srp=RACK&amenity=&sstate_country=&
city_code=&dateFormat=mm/dd/yy&arrivalDate=06/25/10&departureDate=06/27/10
&nroom=1&nadult1=1&nchild1=0&nadult2=&nchild2=&nadult3=&nchild3=&nadult4=&
nchild4=&nadult5=&nchild5= |
|
y****w 发帖数: 3747 | 7 SET DATEFORMAT
google "sql server bcp date format" |
|
m******t 发帖数: 2416 | 8
Using java.text.DateFormat would relieve you from hassles like this,
man. |
|
d*r 发帖数: 238 | 9 Met a strange question:
I tried to set a date and output it:
Calendar c = new GregorianCalendar(2003, 12, 1); // set the calendar to
12/1/2003
System.out.println(DateFormat.getDateInstance().format(c)); // output
The output is Jan 1, 2004.
Who knows what's the problem?
I am using java 1.4.1 |
|
l**s 发帖数: 28 | 10 the following code generates the result as:
Current TimeZone:America/New_York
before parse:2003-11-15 16:42:05 EST
after parse:2003-11-15 16:42:05 EST
Timezone change to:Australia/Sydney
before parse:2003-11-16 08:42:05 EST
after parse:2003-11-16 09:42:05 EST
it had 1 hour different in Australia/Sydney timezone(called EST too) before
and after the parsing.
could someone please tell me why?
Thanks.
=================================================================
import java.util.TimeZone;
impo |
|
l**s 发帖数: 28 | 11 BTW, the problem happens only in the Australia TimeZones
Australia/Adelaide
Australia/Broken_Hill
Australia/South
Australia/Yancowinna
AET
Australia/ACT
Australia/Canberra
Australia/Hobart
Australia/Melbourne
Australia/NSW
Australia/Sydney
Australia/Tasmania
Australia/Victoria
right now it's summer there and they use DayLightSaving time, so it might be
somewhere messed up when handling the DST in Australia. |
|
l**s 发帖数: 28 | 12 Australia starts DST on the last Sunday in October
the parse works fine if in standard time(non-DST) in Australia timezone |
|
B**z 发帖数: 153 | 13 see Java bug database bug ID # 4856901, status:in progress
last updated on 2003-11-06. |
|
m******t 发帖数: 2416 | 14
JAVA
期
StringTokenizer probably isn't the best way. Use java.text.DateFormat to parse
the whole string into a date. |
|
g******i 发帖数: 32 | 15 不太明白,这个DateFormat 需要怎样和文件流结合起来用呢?
另外,JAVA是否有方式(比如不用StringTokenizer)可以象C++读文件一样只将空白符做为
分隔符而不考虑其他任何特殊字符呢?
parse |
|
u****s 发帖数: 2186 | 16 some of them are real questions asked in tests or interviews.
question 1. is to solve a SQLSever 2005 bug, it won't parse UTC dateformat
for non-English locale, the bug is fixed in SQLServer 2008. |
|
c*******e 发帖数: 290 | 17 这个没有任何 thread safety 的保护,但好像是安全的。为什么?
public class ThreadLocalTest {
public static void main(String args[]) throws IOException {
Thread t1 = new Thread(new Task());
Thread t2 = new Thread( new Task());
t1.start();
t2.start();
}
public static String threadSafeFormat(Date date){
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
return formatter.format(date);
}
}
class Task implements Runnable{
@Ov... 阅读全帖 |
|
a********i 发帖数: 205 | 18 你直接用proc sql调用这个表的话就input(varibale,dateformat,)
如果用infile建立dataset就在input后面加informat就行了 |
|
a********i 发帖数: 205 | 19
那你是用proc import导入的
前面两种方法就不是了
那你直接用
data a;
set a;
var=input(var,dateformat,);
run;
这样应该可以 |
|