com.zaradai.bloodstone.system.actions.CurrentTime.java Source code

Java tutorial

Introduction

Here is the source code for com.zaradai.bloodstone.system.actions.CurrentTime.java

Source

/**
 * Copyright 2014 Zaradai
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.zaradai.bloodstone.system.actions;

import com.zaradai.bloodstone.annotations.ActionDefinition;
import com.zaradai.bloodstone.annotations.PropertyDefinition;
import com.zaradai.bloodstone.execution.flow.AbstractAction;
import com.zaradai.bloodstone.execution.flow.ActivityResult;
import com.zaradai.bloodstone.text.Constants;
import org.joda.time.DateTime;

import java.util.Date;

@ActionDefinition(name = "CurrentTime", shortDescription = "Get the current system time.", category = Constants.CATEGORY_NAME)
public class CurrentTime extends AbstractAction {
    @PropertyDefinition(name = "date", description = "The current time as a Date.", nullable = true, input = false, output = true)
    private Date date;

    @PropertyDefinition(name = "millis", description = "The current time as a long in milliseconds.", nullable = true, input = false, output = true)
    private long millis;

    @Override
    public ActivityResult execute() throws Exception {
        DateTime now = DateTime.now();

        date = now.toDate();
        millis = now.getMillis();

        return ActivityResult.SUCCESS;
    }
}