Java Rant
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad: -
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad:My bet is there's an easier way to do this. I'm not Java expert, but I do know that what's easy in .NET is usually reflected in Java.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Who is Jewish, the Trivia Game! Judah Himango
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad:Nu Er Ha Chi wrote: How do I build a string as time stamp based on the current time? Not the proper forum to answer. Nu Er Ha Chi wrote: What the ****? As much as I don't like Java, I bet one can also find a lot of situations where Java requires a lot less coding than .NET. I see dead pixels Yes, even I am blogging now!
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad:Nu Er Ha Chi wrote: Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, hehehe - I wondered much about that as well when I used Java, I never found a decent answer but wrote it off as a bug. --------------------------- 127.0.0.1 - Sweet 127.0.0.1
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad: -
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad: -
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad: -
Yes, it does. Thanks.
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad:Nu Er Ha Chi wrote: I haven't used Java for a while. And before that you didn't do much either I presume :-) "God doesn't play dice" - Albert Einstein "God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
-
I haven't used Java for a while. My company is moving from .NET to Java, so I downloaded the most recent version of J2SE (5.0). I hate it already. How do I build a string as time stamp based on the current time? The format I want is: yyyyMMddHHmmss (i.e. year, month, day, hour, minute, second) With .NET, I need only to do this:
string sTimestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
Here is what I have to do in Java:GregorianCalendar oCal = new GregorianCalendar(); int nYear = oCal.get(Calendar.YEAR); int nMonth = oCal.get(Calendar.MONTH); int nDay = oCal.get(Calendar.DAY_OF_MONTH); int nAMPM = oCal.get(Calendar.AM_PM); int nHour = nAMPM>0?(oCal.get(Calendar.HOUR)+12):oCal.get(Calendar.HOUR); int nMinute = oCal.get(Calendar.MINUTE); int nSecond = oCal.get(Calendar.SECOND); String sTimestamp = new Integer(nYear).toString()+ (nMonth<9?("0"+new Integer(nMonth+1).toString()):new Integer(nMonth+1).toString())+ (nDay<10?("0"+new Integer(nDay).toString()):new Integer(nDay).toString())+ (nHour<10?("0"+new Integer(nHour).toString()):new Integer(nHour).toString())+ (nMinute<10?("0"+new Integer(nMinute).toString()):new Integer(nMinute).toString())+ (nSecond<10?("0"+new Integer(nSecond).toString()):new Integer(nSecond).toString());
Note that the month value returned by oCal.get(Calendar.MONTH) is 0 based, unlike all the other fields. What the ****? :mad:Nu Er Ha Chi wrote: My company is moving from .NET to Java Wow. First time I ever heard someone going that direction. Seems rather backwards to me. Maybe after spending a year on Java, they'll want you to move to VB next. :-D Marc My website
Latest Articles: Object Comparer String Helpers -
Nu Er Ha Chi wrote: My company is moving from .NET to Java Wow. First time I ever heard someone going that direction. Seems rather backwards to me. Maybe after spending a year on Java, they'll want you to move to VB next. :-D Marc My website
Latest Articles: Object Comparer String HelpersMarc Clifton wrote: Maybe after spending a year on Java, they'll want you to move to VB next. Cobol would be a better choice.
My name is Maximus Decimus Meridius, commander of the Armies of the North, General of the Felix Legions, loyal servant to the true emperor, Marcus Aurelius. Father to a murdered son, husband to a murdered wife. And I will finish this project, in this life or the next. Slightly modified " from Gladiator. Code-frog System Architects, Inc.
-
Nu Er Ha Chi wrote: My company is moving from .NET to Java Wow. First time I ever heard someone going that direction. Seems rather backwards to me. Maybe after spending a year on Java, they'll want you to move to VB next. :-D Marc My website
Latest Articles: Object Comparer String HelpersMarc Clifton wrote: Seems rather backwards to me. Maybe they have customers who want their software to run on Unix.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
-
Marc Clifton wrote: Seems rather backwards to me. Maybe they have customers who want their software to run on Unix.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
-
Marc Clifton wrote: Seems rather backwards to me. Maybe they have customers who want their software to run on Unix.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
I think there are versions of the CLR which will run on linux.
-
I think there are versions of the CLR which will run on linux.
For example Mono. Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy -
Do you know that you can actually turn the CAPS LOCK off? Just hit it again... :rolleyes: Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy -
Do you know that you can actually turn the CAPS LOCK off? Just hit it again... :rolleyes: Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy -
Nothing personal, just your pleaure for uppercase letters and my averse to them, plus your great sense of humor makes you target :P Easy, Alex. ;) Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy -
Nothing personal, just your pleaure for uppercase letters and my averse to them, plus your great sense of humor makes you target :P Easy, Alex. ;) Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy