Package java.util

Examples of java.util.SimpleTimeZone


  protected Calendar getCalendar() {
    String[] ids = TimeZone.getAvailableIDs(0);
    if (ids.length < 1) {
      return null;
    }
    TimeZone gmt = new SimpleTimeZone(0, ids[0]);
    return new GregorianCalendar(gmt);   
  }
View Full Code Here


  private static Calendar getCalendar() {
    String[] ids = TimeZone.getAvailableIDs(0);
    if (ids.length < 1) {
      return null;
    }
    TimeZone gmt = new SimpleTimeZone(0, ids[0]);
    return new GregorianCalendar(gmt);   
  }
View Full Code Here

                ttl = getServerConfig().getMessageTimeToLive();
            }
           
            long timeToLive = 0;
            if (request.getJMSExpiration() > 0) {
                TimeZone tz = new SimpleTimeZone(0, "GMT");
                Calendar cal = new GregorianCalendar(tz);
                timeToLive =  request.getJMSExpiration() - cal.getTimeInMillis();
            }
           
            if (timeToLive >= 0) {
View Full Code Here

            }

            Destination replyTo = getReplyToDestination(jmsTemplate, inMessage);

            if (request.getJMSExpiration() > 0) {
                TimeZone tz = new SimpleTimeZone(0, "GMT");
                Calendar cal = new GregorianCalendar(tz);
                long timeToLive = request.getJMSExpiration() - cal.getTimeInMillis();
                if (timeToLive < 0) {
                    getLogger()
                        .log(Level.INFO, "Message time to live is already expired skipping response.");
View Full Code Here

            int minute = 0;
            int second = 0;
            //first string off the prefix if it exists
            try
            {
                SimpleTimeZone zone = null;
                if( date.startsWith( "D:" ) )
                {
                    date = date.substring( 2, date.length() );
                }
                if( date.length() < 4 )
                {
                    throw new IOException( "Error: Invalid date format '" + date + "'" );
                }
                year = Integer.parseInt( date.substring( 0, 4 ) );
                if( date.length() >= 6 )
                {
                    month = Integer.parseInt( date.substring( 4, 6 ) );
                }
                if( date.length() >= 8 )
                {
                    day = Integer.parseInt( date.substring( 6, 8 ) );
                }
                if( date.length() >= 10 )
                {
                    hour = Integer.parseInt( date.substring( 8, 10 ) );
                }
                if( date.length() >= 12 )
                {
                    minute = Integer.parseInt( date.substring( 10, 12 ) );
                }
                if( date.length() >= 14 )
                {
                    second = Integer.parseInt( date.substring( 12, 14 ) );
                }

                if( date.length() >= 15 )
                {
                    char sign = date.charAt( 14 );
                    if( sign == 'Z' )
                    {
                        zone = new SimpleTimeZone(0,"Unknown");
                    }
                    else
                    {
                        int hours = 0;
                        int minutes = 0;
                        if( date.length() >= 17 )
                        {
                            if( sign == '+' )
                            {
                                //parseInt cannot handle the + sign
                                hours = Integer.parseInt( date.substring( 15, 17 ) );
                            }
                            else
                            {
                                hours = -Integer.parseInt( date.substring( 14, 16 ) );
                            }
                        }
                        if( date.length() > 20 )
                        {
                            minutes = Integer.parseInt( date.substring( 18, 20 ) );
                        }
                        zone = new SimpleTimeZone( hours*60*60*1000 + minutes*60*1000, "Unknown" );
                    }
                }
                if( zone != null )
                {
                    retval = new GregorianCalendar( zone );
View Full Code Here

            int minute = 0;
            int second = 0;
            //first string off the prefix if it exists
            try
            {
                SimpleTimeZone zone = null;
                if( date.startsWith( "D:" ) )
                {
                    date = date.substring( 2, date.length() );
                }
                date = date.replaceAll("[-:T]", "");
               
                if( date.length() < 4 )
                {
                    throw new IOException( "Error: Invalid date format '" + date + "'" );
                }
                year = Integer.parseInt( date.substring( 0, 4 ) );
                if( date.length() >= 6 )
                {
                    month = Integer.parseInt( date.substring( 4, 6 ) );
                }
                if( date.length() >= 8 )
                {
                    day = Integer.parseInt( date.substring( 6, 8 ) );
                }
                if( date.length() >= 10 )
                {
                    hour = Integer.parseInt( date.substring( 8, 10 ) );
                }
                if( date.length() >= 12 )
                {
                    minute = Integer.parseInt( date.substring( 10, 12 ) );
                }
                if( date.length() >= 14 )
                {
                    second = Integer.parseInt( date.substring( 12, 14 ) );
                }
                if( date.length() >= 15 )
                {
                    char sign = date.charAt( 14 );
                    if( sign == 'Z' )
                    {
                        zone = new SimpleTimeZone(0,"Unknown");
                    }
                    else
                    {
                        int hours = 0;
                        int minutes = 0;
                        if( date.length() >= 17 )
                        {
                            if( sign == '+' )
                            {
                                //parseInt cannot handle the + sign
                                hours = Integer.parseInt( date.substring( 15, 17 ) );
                            }
                            else
                            {
                                hours = -Integer.parseInt( date.substring( 14, 16 ) );
                            }
                        }
                        if( sign=='+' )
                        {
                            if( date.length() >= 19 )
                            {
                                minutes = Integer.parseInt( date.substring( 17, 19 ) );
                            }
                        }
                        else
                        {
                            if( date.length() >= 18 )
                            {
                                minutes = Integer.parseInt( date.substring( 16, 18 ) );
                            }
                        }
                        zone = new SimpleTimeZone( hours*60*60*1000 + minutes*60*1000, "Unknown" );
                    }
                }
                if( zone == null )
                {
                    retval = new GregorianCalendar();
View Full Code Here

   {
      parse_1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
      parse_850 = new SimpleDateFormat("EEEE, dd-MMM-yy HH:mm:ss 'GMT'", Locale.US);
      parse_asctime = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.US);

      parse_1123.setTimeZone(new SimpleTimeZone(0, "GMT"));
      parse_850.setTimeZone(new SimpleTimeZone(0, "GMT"));
      parse_asctime.setTimeZone(new SimpleTimeZone(0, "GMT"));

      parse_1123.setLenient(true);
      parse_850.setLenient(true);
      parse_asctime.setLenient(true);
   }
View Full Code Here

   }

   private static final void setupFormatter()
   {
      http_format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'", Locale.US);
      http_format.setTimeZone(new SimpleTimeZone(0, "GMT"));
   }
View Full Code Here

    harness.check(!f1.equals(f2));
    c2.setMinimalDaysInFirstWeek(6);
    harness.check(f1.equals(f2));
   
    // timeZone
    c1.setTimeZone(new SimpleTimeZone(0, "Z1"));
    harness.check(!f1.equals(f2));
    c2.setTimeZone(new SimpleTimeZone(0, "Z1"));
    harness.check(f1.equals(f2));
   
    // locale
    c1 = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK);
    c2 = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.US);
View Full Code Here

    test2(harness);
  }

  private void test1(TestHarness harness)
  {
    SimpleTimeZone z1 = new SimpleTimeZone(5 * 60 * 60 * 1000, "Z1");
    harness.check(!z1.equals(null));
   
    SimpleTimeZone z2 = new SimpleTimeZone(5 * 60 * 60 * 1000, "Z1");
  harness.check(z1.equals(z2));    // check 1
  harness.check(z2.equals(z1));    // check 2
 
  int rawOffset1 = 5 * 60 * 60 * 1000;
  int rawOffset2 = 6 * 60 * 60 * 1000;
  int time1 = 2 * 60 * 60 * 1000;
  int time2 = 3 * 60 * 60 * 1000;
 
  z1 = new SimpleTimeZone(rawOffset1, "Z1", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  z2 = new SimpleTimeZone(rawOffset1, "Z1", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 3
 
  z1 = new SimpleTimeZone(rawOffset2, "Z1", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 4
  z2 = new SimpleTimeZone(rawOffset2, "Z1", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 5

  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 6
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.APRIL, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 7
 
  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 8
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 5, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 9

  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 10
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time1, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 11
 
  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 12
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.SEPTEMBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 13
 
  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 15, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 14
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 15, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 15

  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time2, 3600000);
  harness.check(!z1.equals(z2));   // check 16
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time2, 3600000);
  harness.check(z1.equals(z2));    // check 17
 
  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time1, 3600000);
  harness.check(!z1.equals(z2));   // check 18
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time1, 3600000);
  harness.check(z1.equals(z2));    // check 19
 
  z1 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time1, 3600001);
  harness.check(!z1.equals(z2));   // check 20
  z2 = new SimpleTimeZone(rawOffset2, "Z2", Calendar.MAY, 6, 0, time2, Calendar.OCTOBER, 16, 0, time1, 3600001);
  harness.check(z1.equals(z2));    // check 21
 
  }
View Full Code Here

TOP

Related Classes of java.util.SimpleTimeZone

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.