Results 1 to 2 of 2
  1. #1
    barryc is offline Member
    Join Date
    Jul 2008
    Rep Power

    Default Coercing DataTypes

    I have a calendar that gives me times in milliseconds of datatype long. How do I stuff this into a control that requires a java.util.Calendar datatype?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    A way to find which class to use is to look at the API doc for the constructors and see how to get from a long to a Calendar. There might be a class that will span that gap.
    Something like:
    Calendar cal = new Calendar(new ?????(long));
    where ???? is the spanning class.

    Since Calendar is abstract, you'll need to use a subclass.

    Or perhaps there is a method in the class/subclass that takes an object that uses a long in its constructor:

    Calendar cal = new Calendar().setTheDate(new ????(long));

    You find these by looking thru the possible methods and classes and see how to get from long to Calendar.
    Good luck.
    Last edited by Norm; 07-09-2008 at 06:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts