Example usage for java.util GregorianCalendar toString

List of usage examples for java.util GregorianCalendar toString

Introduction

In this page you can find the example usage for java.util GregorianCalendar toString.

Prototype

@Override
public String toString() 

Source Link

Document

Return a string representation of this calendar.

Usage

From source file:com.jmstudios.redmoon.receiver.AutomaticFilterChangeReceiver.java

public static void scheduleNextAlarm(Context context, String time, Intent operation) {
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time.split(":")[0]));
    calendar.set(Calendar.MINUTE, Integer.parseInt(time.split(":")[1]));

    GregorianCalendar now = new GregorianCalendar();
    now.add(Calendar.SECOND, 1);/*  w  ww  . j a  v  a2 s  . co  m*/
    if (calendar.before(now)) {
        calendar.add(Calendar.DATE, 1);
    }

    if (DEBUG)
        Log.i(TAG, "Scheduling alarm for " + calendar.toString());

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);

    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, operation, 0);

    if (android.os.Build.VERSION.SDK_INT >= 19) {
        alarmManager.setExact(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent);
    } else {
        alarmManager.set(AlarmManager.RTC, calendar.getTimeInMillis(), pendingIntent);
    }
}

From source file:com.daveoxley.cbus.events.DebugEventCallback.java

@Override
public void processEvent(CGateSession cgate_session, int event_code, GregorianCalendar event_time,
        String event) {/*  w  w w  .j a  v a  2s  .c om*/
    log.debug("event_code: " + event_code + ", event_time: " + event_time.toString() + ", event: " + event);
}

From source file:org.apache.juddi.validation.ValidateSubscription.java

public void validateGetSubscriptionResults(EntityManager em, GetSubscriptionResults body)
        throws DispositionReportFaultMessage {
    // No null input
    if (body == null) {
        throw new FatalErrorException(new ErrorMessage("errors.NullInput"));
    }/*from w w  w . j a  v a2s  . com*/

    String subscriptionKey = body.getSubscriptionKey();
    if (subscriptionKey == null || subscriptionKey.length() == 0) {
        throw new InvalidKeyPassedException(new ErrorMessage("errors.invalidkey.NullKey", subscriptionKey));
    }

    // Per section 4.4: keys must be case-folded
    subscriptionKey = subscriptionKey.toLowerCase();
    body.setSubscriptionKey(subscriptionKey);

    Object obj = em.find(org.apache.juddi.model.Subscription.class, subscriptionKey);
    if (obj == null) {
        throw new InvalidKeyPassedException(
                new ErrorMessage("errors.invalidkey.SubscriptionNotFound", subscriptionKey));
    }

    Date expiresAfter = ((org.apache.juddi.model.Subscription) obj).getExpiresAfter();
    Date now = new Date();
    if (expiresAfter.getTime() < now.getTime()) {
        throw new InvalidKeyPassedException(
                new ErrorMessage("errors.getsubscriptionresult.SubscriptionExpired", subscriptionKey));
    }

    CoveragePeriod coveragePeriod = body.getCoveragePeriod();
    if (coveragePeriod == null) {
        throw new InvalidTimeException(new ErrorMessage("errors.getsubscriptionresult.NullCoveragePeriod"));
    }

    if (coveragePeriod.getStartPoint() == null || coveragePeriod.getEndPoint() == null) {
        throw new InvalidTimeException(
                new ErrorMessage("errors.getsubscriptionresult.InvalidDateInCoveragePeriod"));
    }

    GregorianCalendar startPoint = coveragePeriod.getStartPoint().toGregorianCalendar();
    GregorianCalendar endPoint = coveragePeriod.getEndPoint().toGregorianCalendar();
    if (startPoint.getTimeInMillis() > endPoint.getTimeInMillis()) {
        throw new InvalidTimeException(new ErrorMessage("errors.getsubscriptionresult.StartPointAfterEndPoint",
                startPoint.toString()));
    }
}

From source file:com.xmlcalabash.core.XProcRuntime.java

public String getEpisode() {
    if (episode == null) {
        MessageDigest digest = null;
        GregorianCalendar calendar = new GregorianCalendar();
        try {//  www  .ja  v a 2 s. co m
            digest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException nsae) {
            throw XProcException.dynamicError(36);
        }

        byte[] hash = digest.digest(calendar.toString().getBytes());
        episode = "CB";
        for (byte b : hash) {
            episode = episode + Integer.toHexString(b & 0xff);
        }
    }

    return episode;
}