OK since this list
is active now, let's use it in a productive way and may be leave something
for new users...
I am getting a date
time field in Java and it's description is: public
java.util.GregorianCalendar
when I do say '
field : ' field I get
field : java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,
dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=-17776,MONTH=-177,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=-176,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=-176,MINUTE=-176,SECOND=-176,MILLISECOND=-1760,ZONE_OFFSET=?,DST_OFFSET=?] I could start parsing this
myself, but I am sure there must be shortcut to converting this field to
DD-MM-YYYY HH:MM:SS somehow with a
function.
this is the part which for java people is a walk in the
park, but for me ... it's a head scratcher... and don't want to take the long
way home...
so any hints on how
to do this?
Thanks,
Michael
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
The Java doc for GregorianCalendar says that it should be easy to get
what you want:
// print out a bunch of interesting things System.out.println("ERA: " + calendar.get(Calendar.ERA)); System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR)); System.out.println("WEEK_OF_MONTH: " + calendar.get(Calendar.WEEK_OF_MONTH)); System.out.println("DATE: " + calendar.get(Calendar.DATE)); System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH)); System.out.println("DAY_OF_YEAR: " + calendar.get(Calendar.DAY_OF_YEAR)); System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK)); System.out.println("DAY_OF_WEEK_IN_MONTH: " + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH)); System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); System.out.println("HOUR: " + calendar.get(Calendar.HOUR)); System.out.println("HOUR_OF_DAY: " + calendar.get(Calendar.HOUR_OF_DAY)); System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE)); System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); System.out.println("MILLISECOND: " + calendar.get(Calendar.MILLISECOND)); System.out.println("ZONE_OFFSET: " + (calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000))); System.out.println("DST_OFFSET: " + (calendar.get(Calendar.DST_OFFSET)/(60*60*1000))); This seems to work pretty well (I tested it with NetRexxScript - not sure why January is month zero): field = GregorianCalendar() DD=field.get(Calendar.DAY_OF_MONTH) MM=field.get(Calendar.MONTH)+1 YYYY=field.get(Calendar.YEAR) HH=field.get(Calendar.HOUR) MIN=field.get(Calendar.MINUTE) SS=field.get(Calendar.SECOND) say DD'-'MM'-'YYYY HH':'MIN':'SS -- Kermit Michael Dag wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
El 12/03/2010 10:58, Kermit Kiser escribió: > This seems to work pretty well (I tested it with NetRexxScript - not > sure why January is month zero): This is one of the longest standing complaints against the java library spec. And also one which nothing can be done about as it would break huge amounts of existing code.. --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Michael Dag
Michael, you are getting a “Calendar” object.
It is pretty cool that say dumps the values. Kermit’s note shows
all the methods. Don’t confuse this with the “Date”
object. (having fun yet?) The “Date” object is seconds since midnight, Jan 1
1970, at the point you request it. Most of Date is also depreciated. The Calendar object is any date/time you want, with the default
being right now, hence: whenStarted = Date() do someStuff … End whenEnded = Date() timeSpent = whenEnded – whenStarted say ‘that took ‘ timeSpent ‘ milliseconds /************************************/ myCal = Calendar.getInstance()
-- get a calendar object defaults to “Now” and current
timezone --Some other handy things –
the simpledateformat f1 = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") myDateMilliseconds = 1268397088 myReadableDate = f1.format(myDateMilliseconds) say ‘some random date ‘ myReadableDate say ‘and right now is ‘ f1.format(myCal.gettime()) /* the reverse of format is parse – so to make a string
into a date */ f2 = SimpleDateFormat(“yyyy-MM-dd”) myStringDate = ”1957-09-07” myDate = f2.parse(myStringDate) myCal.setTime(myDate) From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael Dag OK
since this list is active now, let's use it in a productive way and may be
leave something for new users... I
am getting a date time field in Java and it's description is: public
java.util.GregorianCalendar when
I do say ' field : ' field I get field
: java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0, I
could start parsing this myself, but I am sure there must be shortcut to
converting this field to DD-MM-YYYY HH:MM:SS somehow with a function. this
is the part which for java people is a walk in the park, but for me ... it's a
head scratcher... and don't want to take the long way home... so
any hints on how to do this? Thanks, Michael _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Michael Dag
Hi Michael,
In Chapter 6, "Dates and Times" of "Java Cookbook" (O'Reilly), Ian F. Darwin advises "Do not try to use a GregorianCalendar's toString() method; the results are truly impressive, but not very interesting." This is what you have done (it sounds like a reasonable approach to most everyone). I expect you would find article 6.2. "Printing Date/Time in a specified Format" rewarding, in particular the discussion of the SimpleDateFormat class, which will format dates and times in a wide variety of ways when given a simple template string. Java dates are complicated because the issue is truly complicated. Trying to sort this out by reading javadocs is the way to madness. I can't recommend Darwin's book highly enough. George Hovey On Fri, Mar 12, 2010 at 4:07 AM, Michael Dag <[hidden email]> wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
All,
thanks for the hints and tips it makes a little more sense
now!!!
on to the next challenge :-) From: [hidden email] [mailto:[hidden email]] On Behalf Of George Hovey Sent: vrijdag 12 maart 2010 15:44 To: IBM Netrexx Subject: Re: [Ibm-netrexx] How-To: Date conversion ? In Chapter 6, "Dates and Times" of "Java Cookbook" (O'Reilly), Ian F. Darwin advises "Do not try to use a GregorianCalendar's toString() method; the results are truly impressive, but not very interesting." This is what you have done (it sounds like a reasonable approach to most everyone). I expect you would find article 6.2. "Printing Date/Time in a specified Format" rewarding, in particular the discussion of the SimpleDateFormat class, which will format dates and times in a wide variety of ways when given a simple template string. Java dates are complicated because the issue is truly complicated. Trying to sort this out by reading javadocs is the way to madness. I can't recommend Darwin's book highly enough. George Hovey On Fri, Mar 12, 2010 at 4:07 AM, Michael Dag <[hidden email]>
wrote:
_______________________________________________ Ibm-netrexx mailing list [hidden email] |
May I add that 'date' and 'time' (in the classic Rexx sense & syntax)
are part of the Rexx2Nrx run-time (see www.rexx2Nrx.com) Tom. ==================================== Michael Dag schrieb: > All, > thanks for the hints and tips it makes a little more sense now!!! > > on to the next challenge :-) > > ------------------------------------------------------------------------ > *From:* [hidden email] > [mailto:[hidden email]] *On Behalf Of *George Hovey > *Sent:* vrijdag 12 maart 2010 15:44 > *To:* IBM Netrexx > *Subject:* Re: [Ibm-netrexx] How-To: Date conversion ? > > Hi Michael, > > In Chapter 6, "Dates and Times" of "Java Cookbook" (O'Reilly), Ian F. > Darwin advises "Do not try to use a GregorianCalendar's toString() > method; the results are truly impressive, but not very interesting." > This is what you have done (it sounds like a reasonable approach to > most everyone). > > I expect you would find article 6.2. "Printing Date/Time in a > specified Format" rewarding, in particular the discussion of the > SimpleDateFormat class, which will format dates and times in a wide > variety of ways when given a simple template string. > > Java dates are complicated because the issue is truly complicated. > Trying to sort this out by reading javadocs is the way to madness. I > can't recommend Darwin's book highly enough. > > George Hovey > > > > On Fri, Mar 12, 2010 at 4:07 AM, Michael Dag > <[hidden email] <mailto:[hidden email]>> wrote: > > OK since this list is active now, let's use it in a productive way > and may be leave something for new users... > > I am getting a date time field in Java and it's description is: > public java.util.GregorianCalendar > when I do say ' field : ' field I get > > field : > java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0, > dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=-17776,MONTH=-177,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=-176,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=-176,MINUTE=-176,SECOND=-176,MILLISECOND=-1760,ZONE_OFFSET=?,DST_OFFSET=?] > > I could start parsing this myself, but I am sure there must be > shortcut to converting this field to DD-MM-YYYY HH:MM:SS somehow > with a function. > > this is the part which for java people is a walk in the park, but > for me ... it's a head scratcher... and don't want to take the > long way home... > > so any hints on how to do this? > > Thanks, > Michael > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] <mailto:[hidden email]> > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
In reply to this post by Michael Dag
To what are they converted? _______________________________________________ Ibm-netrexx mailing list [hidden email] |
My implementation of date and time return Rexx values and have the same
parameters like the original definition of M.F.Cwloshaw in his book 'The Rexx Language"). Internally, of course, they do use the Java Gregoriar and Calendar methods. I'm just in progress to open source all of this stuff at www.Kenai. Project 'reyc'. Tom. ======================================================== Measel, Mike schrieb: > > To what are they converted? > > ----- Original Message ----- > From: [hidden email] > <[hidden email]> > To: IBM Netrexx <[hidden email]> > Sent: Sat Mar 13 05:46:04 2010 > Subject: Re: [Ibm-netrexx] How-To: Date conversion ? > > May I add that 'date' and 'time' (in the classic Rexx sense & syntax) > are part of the Rexx2Nrx run-time > (see www.rexx2Nrx.com) > > Tom. > ==================================== > Michael Dag schrieb: > > All, > > thanks for the hints and tips it makes a little more sense now!!! > > > > on to the next challenge :-) > > > > ------------------------------------------------------------------------ > > *From:* [hidden email] > > [mailto:[hidden email]] *On Behalf Of *George Hovey > > *Sent:* vrijdag 12 maart 2010 15:44 > > *To:* IBM Netrexx > > *Subject:* Re: [Ibm-netrexx] How-To: Date conversion ? > > > > Hi Michael, > > > > In Chapter 6, "Dates and Times" of "Java Cookbook" (O'Reilly), Ian F. > > Darwin advises "Do not try to use a GregorianCalendar's toString() > > method; the results are truly impressive, but not very interesting." > > This is what you have done (it sounds like a reasonable approach to > > most everyone). > > > > I expect you would find article 6.2. "Printing Date/Time in a > > specified Format" rewarding, in particular the discussion of the > > SimpleDateFormat class, which will format dates and times in a wide > > variety of ways when given a simple template string. > > > > Java dates are complicated because the issue is truly complicated. > > Trying to sort this out by reading javadocs is the way to madness. I > > can't recommend Darwin's book highly enough. > > > > George Hovey > > > > > > > > On Fri, Mar 12, 2010 at 4:07 AM, Michael Dag > > <[hidden email] <mailto:[hidden email]>> > wrote: > > > > OK since this list is active now, let's use it in a productive way > > and may be leave something for new users... > > > > I am getting a date time field in Java and it's description is: > > public java.util.GregorianCalendar > > when I do say ' field : ' field I get > > > > field : > > > java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0, > > > dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=?,YEAR=-17776,MONTH=-177,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=-176,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=-176,MINUTE=-176,SECOND=-176,MILLISECOND=-1760,ZONE_OFFSET=?,DST_OFFSET=?] > > > > I could start parsing this myself, but I am sure there must be > > shortcut to converting this field to DD-MM-YYYY HH:MM:SS somehow > > with a function. > > > > this is the part which for java people is a walk in the park, but > > for me ... it's a head scratcher... and don't want to take the > > long way home... > > > > so any hints on how to do this? > > > > Thanks, > > Michael > > > > _______________________________________________ > > Ibm-netrexx mailing list > > [hidden email] <mailto:[hidden email]> > > > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Ibm-netrexx mailing list > > [hidden email] > > > > > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > > ------------------------------------------------------------------------ > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > > _______________________________________________ Ibm-netrexx mailing list [hidden email]
Tom. (ths@db-123.com)
|
Free forum by Nabble | Edit this page |