Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

change calendar

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


What I want to do is: Given a timestamp of Milliseconds (say 12345678L), I want to get a Calendar that is on the same day as "12345678L" but is at 6:00AM. Does this code achieve that ? I think so but want to hear from you.
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

mark I thomas wrote:

What I want to do is: Given a timestamp of Milliseconds (say 12345678L), I want to get a Calendar that is on the same day as "12345678L" but is at 6:00AM. Does this code achieve that ? I think so but want to hear from you.



not exactly. What happens when you run this and print out the entire date and time?
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
It worked fine for me. here is the sample code



The output is:

date = Tue Sep 04 06:00:47 EDT 2012

Since I didn't reset the "Second" so it copied whatever runtime second value over, but it is good enough for proof of concept.

Any problem ?
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
if you say it is good enough, then it is good enough! How could I have a problem with that?
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Tim McGuire wrote:if you say it is good enough, then it is good enough! How could I have a problem with that?



Well, Nobody forced you to give idea if you don't have one. If you have, please get to the point so we can understand you.
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks Campbell. Still waiting to receive some meaningful response for the question I asked.
 
Greenhorn
Posts: 14
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


OUTPUT
jmaster@Jmaster:~/Desktop$ javac Test.java
jmaster@Jmaster:~/Desktop$ java Test
Current time is : Thu Jan 01 08:55:45 IST 1970
Modified time is : Thu Jan 01 06:00:45 IST 1970

Your code was achieving what you desired for such things you first put your efforts, and do google and find the results then if still facing any problem post your queries...
ADVICE : and be cool when you are on java racnh if some one is devoting time to give answer you must value that no one is forced to give answer but if any one is giving and it don't satisfy you don't put a finger on him/her.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

mark I thomas wrote:Still waiting to receive some meaningful response for the question I asked.


Actually, Tim's response was right on the money; and when you actually did what he suggested, you answered your own question - or doesn't "proof of concept" mean the same thing to you as it does to me.

What more do you need to know?

Winston
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I already tested my code (by the way it was not from any google..). But I didn't feel 100% sure if I can overwrite an existing timeinMillion so I don't know if there is any potential problem -- and that's why I posted the question.

Tim's response started with "Not really..." puzzled me because I didn't know what that "not really.." menas so I was interested in hearing more from that part but unfortunately I didn't get any insight from him.

I thought when someone said "not really..." he must have something interesting in his mind and that's what I expected to hear and discuss with that person.

Tim's second email even confused me more --- It seems he was asking me "If you think there is no problem then why bother asking ?" Well, Most people believe they write the correct code but people still do code review in team, your peers may identify some potential issue that you don't see -- That's exactly why I posted that question.

I think I am very cool.

 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
When I posted my code and question, I said "with a given long timestamp, say 12345678L" this menas "12345678L" is a hypothetic value. In many cases, people post some pseudo code and if you run that it is not going to work. What I expected to discuss is if the idea works. the hypothetic value is too small so you get wrong results as it was on the same day of epoch.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

mark I thomas wrote:I already tested my code (by the way it was not from any google..). But I didn't feel 100% sure if I can overwrite an existing timeinMillion so I don't know if there is any potential problem -- and that's why I posted the question.

Tim's response started with "Not really..." puzzled me because I didn't know what that "not really.." menas so I was interested in hearing more from that part but unfortunately I didn't get any insight from him.

I thought when someone said "not really..." he must have something interesting in his mind and that's what I expected to hear and discuss with that person.

Tim's second email even confused me more --- It seems he was asking me "If you think there is no problem then why bother asking ?" Well, Most people believe they write the correct code but people still do code review in team, your peers may identify some potential issue that you don't see -- That's exactly why I posted that question.

I think I am very cool.


You are cooler than the other side of the pillow.

when you asked " I want to get a Calendar that is on the same day as "12345678L" but is at 6:00AM. Does this code achieve that ? "

I said "not exactly" because I wanted you to see that what you thought was 6:00 was actually 6:00:45. For my alarm clock in the morning, then this is good enough. For the mars lander, maybe not.

When you said the code worked for you anyway, it became funny because I had identified a potential issue but the requirements began shifting under us.
 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Tim McGuire wrote:

mark I thomas wrote:I already tested my code (by the way it was not from any google..). But I didn't feel 100% sure if I can overwrite an existing timeinMillion so I don't know if there is any potential problem -- and that's why I posted the question.

Tim's response started with "Not really..." puzzled me because I didn't know what that "not really.." menas so I was interested in hearing more from that part but unfortunately I didn't get any insight from him.

I thought when someone said "not really..." he must have something interesting in his mind and that's what I expected to hear and discuss with that person.

Tim's second email even confused me more --- It seems he was asking me "If you think there is no problem then why bother asking ?" Well, Most people believe they write the correct code but people still do code review in team, your peers may identify some potential issue that you don't see -- That's exactly why I posted that question.

I think I am very cool.


You are cooler than the other side of the pillow.

when you asked " I want to get a Calendar that is on the same day as "12345678L" but is at 6:00AM. Does this code achieve that ? "

I said "not exactly" because I wanted you to see that what you thought was 6:00 was actually 6:00:45. For my alarm clock in the morning, then this is good enough. For the mars lander, maybe not.

When you said the code worked for you anyway, it became funny because I had identified a potential issue but the requirements began shifting under us.




You should learn to understand when people say "with a given long timestamp, say 12345678L", that "say 12345678L" means "12345678L" is a hypothetic value. Just like I say "with a given city name, say ABCDE"... I will feel sorry for you if you really google map that city "ABCDE" but I still appreciate your effort though. --<End of Story>
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

mark I thomas wrote:You should learn to understand...


Guys, I think you've already been asked once to pipe down. I think the question has been asked and answered.

Mark, unless you feel there is any more life in this thread, I suggest you close it (mark it as 'Resolved').

Winston

 
mark I thomas
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Tim McGuire wrote:

mark I thomas wrote:I already tested my code (by the way it was not from any google..). But I didn't feel 100% sure if I can overwrite an existing timeinMillion so I don't know if there is any potential problem -- and that's why I posted the question.

Tim's response started with "Not really..." puzzled me because I didn't know what that "not really.." menas so I was interested in hearing more from that part but unfortunately I didn't get any insight from him.

I thought when someone said "not really..." he must have something interesting in his mind and that's what I expected to hear and discuss with that person.

Tim's second email even confused me more --- It seems he was asking me "If you think there is no problem then why bother asking ?" Well, Most people believe they write the correct code but people still do code review in team, your peers may identify some potential issue that you don't see -- That's exactly why I posted that question.

I think I am very cool.


You are cooler than the other side of the pillow.

when you asked " I want to get a Calendar that is on the same day as "12345678L" but is at 6:00AM. Does this code achieve that ? "

I said "not exactly" because I wanted you to see that what you thought was 6:00 was actually 6:00:45. For my alarm clock in the morning, then this is good enough. For the mars lander, maybe not.

When you said the code worked for you anyway, it became funny because I had identified a potential issue but the requirements began shifting under us.




Technically if this was your thought you have some problem in understanding my question. I set hour and min so it prints as 6:00 AM -- It does not tell you what is the second because I didn't mention what would be the second I expect. You expected the second to be "0" but that's not what I said in my original question. So when you saw your real time second on your computer got printed out you thought there was some problem. This is like --- I said it it should print as Jan 1st, 2012 but I didn't say anything the hour of clock, somehow you assumed it should be 12AM and when you got a different hour from your clock you interpreted as something was wrong.

No matter if it is 6:00:45 or 6:00:43 or 6:00:23, they are ALL 6:00AM cosidering the hour and minute...
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I think this has now gone off-topic. Locking.

Winston
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    Bookmark Topic Watch Topic
  • New Topic