Package ariba.util.core

Examples of ariba.util.core.Date


        @aribaapi documented
    */
    public static String getStringValue (Date date, Locale locale, TimeZone timeZone)
    {
            // format dates for today with "Today" string
        if (Date.sameDay(date, new Date(date.calendarDate()), timeZone)) {
            String format;
            if (Date.timeIsMidnight(date, timeZone)) {
                format = TodayFormatKey;
            }
            else {
View Full Code Here


        catch (ParseException e)
        {
        }

            // attempt to parse strings like "today", "saturday", etc.
        Date result = parseNaturalDate(string, locale, tz,calendarDate);
        if (result != null) {
            return result;
        }

            // try the localized list of user date formats
View Full Code Here

        /*
            "now" doesn't need to be calendarDate-aware,
            since this is just a temp to find out
            what year, month, and day today is.
        */
        Date now = new Date();

        int thisYear = Date.getYear(now, timeZone, locale);
        int thisMonth = Date.getMonth(now, timeZone, locale);
        int thisDayOfMonth = Date.getDayOfMonth(now, timeZone, locale);
        int thisDayOfWeek = Date.getDayOfWeek(now, timeZone, locale);

        Integer daysToAdd = null;

            // if the user entered a day name, offset into the future to the
            // appropriate day of the month, month, and year
        int dayOfWeek = findDay(string);
        if (dayOfWeek >= 0) {
            int add = ((7 + dayOfWeek) - thisDayOfWeek) % 7;
            if (add == 0) {
                add = 7;
            }
            daysToAdd = Constants.getInteger(add);
        }
            // otherwise, check if the string is a prefix for strings
            // like "today", "tomorrow", etc.
        else {
            for (int i = -1, len = string.length(); i <= 1; i++) {
                String key = RelativeDayKeys[i+1];
                String test = lookupLocalizedFormat(key, locale);
                if (!StringUtil.nullOrEmptyString(test)) {
                    if (test.length() >= len) {
                        String sub = test.substring(0, len);
                        if (sub.equalsIgnoreCase(string)) {
                            daysToAdd = Constants.getInteger(i);
                            break;
                        }
                    }
                }
            }
        }
        Date result = null;
        if (daysToAdd != null) {
            result = new Date(thisYear, thisMonth, thisDayOfMonth,
                                   calendarDate, timeZone, locale);
            Date.addDays(result, daysToAdd.intValue(), timeZone, locale);
            return result;
        }
        else {
                // lastly, try TodayTimeFormatKey.  Get the number of milisecs
                // that the time represent with respect to GMT. Then add on to
                // today's.
            result = parseDateUsingFormats(string, locale,
                     TodayTimeFormatKey, TimeZone.getTimeZone("GMT"), calendarDate);
            if (result != null) {
                Date today = new Date(thisYear, thisMonth, thisDayOfMonth,
                                   calendarDate, timeZone, locale);
                if (result.getTime() < Date.MillisPerDay) {
                    result.setTime(result.getTime() + today.getTime());
                }
            }
            return result;
        }
    }
View Full Code Here

                                           TimeZone timeZone,
                                           boolean calendarDate)
    {
            // parse the date given the year-relative format
        String format = lookupLocalizedFormat(YearRelativeFormat, locale);
        Date date = null;
        try {
            date = parseDate(string, format, locale, timeZone, calendarDate);
        }
        catch (ParseException e) {
            return null;
        }

            // set the year for the date to this year
        Date.setYear(date, Date.getYear(new Date(calendarDate)));

        return date;
    }
View Full Code Here

        if (_didFetchHeader) return;
        _didFetchHeader = true;
        try {
            _from = _message.getFrom()[0].toString();
            _subject = _message.getSubject();
            _sentDate = new Date(_message.getSentDate().getTime());
        } catch (Exception e) {
            _subject = "Error fetching message: " + e.getMessage();
        }
    }
View Full Code Here

                        AWRecordingManager.HeaderSemanticKeyCount);
                response.setHeaderForKey(
                        Integer.toString(semanticKeyTableBytes(response).length),
                                AWRecordingManager.HeaderSemanticKeySize);
            }
            response.setHeaderForKey(new Date().toConciseDateString(), HeaderResponseDate);
            response.setHeaderForKey(new Date().toString(), HeaderResponseDateTime);
        }
    }
View Full Code Here

    public String getHeader ()
    {
        String header =
            Fmt.S("[%s] Start Log.  " // OK
                  "Software Version %s.  %s%s",
                  new Date().toString(),
                  Version.versionImage,
                  Version.copyrightImage,
                  System.getProperty("line.separator"));
        return header;
    }
View Full Code Here

    }

    public Object parseObject (String stringToParse)
    {
        long millis = Long.parseLong(stringToParse);
        return new Date(millis);
    }
View Full Code Here

        return _currentFile.length() / 1024 + 1;
    }

    public String currentFileLastModified ()
    {
        Date lastModifiedDate = new Date(_currentFile.lastModified());
        return DateFormatter.toConciseDateTimeString (lastModifiedDate);
    }
View Full Code Here

     * @return true if in the recycle window.
     * @aribaapi private
     */
    private boolean inRecycleWindow ()
    {
        int hour = Date.getHours(new Date(System.currentTimeMillis()));
        return inRecycleWindow(hour);
    }
View Full Code Here

TOP

Related Classes of ariba.util.core.Date

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.