Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

Wang Kaiyi

Greenhorn
+ Follow
since Feb 02, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Wang Kaiyi

I believe that this will help you...
I think you may study "dateformat" carefully...
package com.kaiyi.test;
import java.text.*;

public class TestSqlDate {
public TestSqlDate() {
}
public static void main(String[] args) {
TestSqlDate testSqlDate1 = new TestSqlDate();
java.sql.Date sqlDate = new java.sql.Date(System.currentTimeMillis());
java.text.SimpleDateFormat simple = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sDate = "2004-02-25 12:12:25";
java.util.Date dDate = new java.util.Date();
try {
dDate = simple.parse(sDate);
}
catch (ParseException ex) {
ex.printStackTrace();
}
System.out.println("------date-------"+dDate.toString());
simple.applyPattern("yyyy-MM-dd HH/mm/ss");
System.out.println("------new Date-------"+simple.format(dDate));
}
}
16 years ago
thank you for your response!But I have a new problem.
I want a String as such format "2004-02-25 12:05:09".
which class and methods can I use?
I tried to do this as following:
java.util.Date dDate = new java.util.Date(System.currentTimeMillis());
String sDate = dDate.dDate.toLocaleString();
then, I execute my program....
the result:
sDate is "2004-02-25 12:05:09" in Windows Environment.(JBuilder9)
sDate is "Feb 25, 2004 12:05:09 AM" in Linux Environment.
I am very confused about this.
What difference can OS make???

and my Linux Environment is as following:
[ken@test47 consumer]$ java -version
java version "1.3.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_01)
Java HotSpot(TM) Client VM (build 1.3.1_01, mixed mode)
[ken@test47 consumer]$ uname -a
Linux test47 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
16 years ago
I have practiced what you advise me to do and succeed in execute my own program by "java com.linktone.sms.consumer.DelayInform".(my package is com.linktone.sms.consumer.)Now, I am confused about that I have set "/com/linktone/sms/consuer" in the CLASSPATH and export it.Why must I use "java com.linktone.sms.consumer.DelayInform" instead of "java DelayInform"?(In my eyes, "java DelayInform" is OK)
16 years ago
Hi, all!
I meet with a fatal Exception which leads to "NoClassDefFoundError";I am suprised to its performance.I can hardly solve it.Can anybody help me?
the following is the process I do...
(DelayInform.java is my program)
[ken@test47 consumer]$ ls De*
Debug.class Debuglycra.class DelayInform.java
[ken@test47 consumer]$ ls De*
Debug.class Debuglycra.class DelayInform.java
[ken@test47 consumer]$ javac -target 1.3 -encoding GBK DelayInform.java
[ken@test47 consumer]$ ls De*
Debug.class Debuglycra.class DelayInform.class DelayInform.java
[ken@test47 consumer]$ java DelayInform
Exception in thread "main" java.lang.NoClassDefFoundError: DelayInform (wrong name: com/linktone/sms/consumer/DelayInform)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
[ken@test47 consumer]$ echo $0
-bash
[ken@test47 consumer]$ uname -a
Linux test47 2.4.18-3 #1 Thu Apr 18 07:37:53 EDT 2002 i686 unknown
16 years ago
Hi,all!
I am confused about "Date" class;
1. I don't know why there is another "Date" in package "java.sql" other than "java.util.Date".
2. And what's the difference between them?

3. In my eyes, the methods of "Date" such as "getDay" "getHours" is very useful, why it is deprecated?
16 years ago
Hi, all, one more thing!
I have read what you said carefully.And some problem arised.
How can I become a good programmer?
How long should I become a excellent programmer if I work hard?
Phil,excellent reply,thank you!
Hi,Jessica and Vad, thank you for your reply! I get it!
Hi, all!
I am a Java beginner.I heard SCJP hundreds of times.I want to clear it.But what 's the most important thing is that is SCJP necessary.In other words, does SCJP help you in your position or salary?