Example usage for java.util GregorianCalendar getTime

List of usage examples for java.util GregorianCalendar getTime

Introduction

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

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:org.talend.repository.metadata.migration.CorrectDBVersionListForAS400.java

@Override
public Date getOrder() {
    GregorianCalendar gc = new GregorianCalendar(2014, 8, 19, 9, 20, 0);
    return gc.getTime();
}

From source file:be.fedict.eid.idp.attribute.age.AgeAttributeService.java

public void addAttribute(Map<String, Attribute> attributeMap) {
    Attribute dobAttribute = attributeMap.get(DefaultAttribute.DATE_OF_BIRTH.getUri());
    if (null == dobAttribute) {
        return;//  w  w  w.  j a  v a  2s .  c  om
    }
    LOG.debug("Add age attribute");
    GregorianCalendar dobValue = (GregorianCalendar) dobAttribute.getValue();
    DateTime dob = new DateTime(dobValue.getTime());
    DateTime now = new DateTime();
    Years years = Years.yearsBetween(dob, now);
    int age = years.getYears();
    attributeMap.put(URI, new Attribute(URI, AttributeType.INTEGER, age));
}

From source file:org.talend.repository.model.migration.CheckAndUpdateStatusMigrationTask.java

public Date getOrder() {
    GregorianCalendar gc = new GregorianCalendar(2012, 3, 15, 17, 0, 0);
    return gc.getTime();
}

From source file:org.power.commons.lang.util.time.DateUtils.java

public static Date getDate(int yyyyMMdd) {
    int dd = yyyyMMdd % 100;
    int yyyyMM = yyyyMMdd / 100;
    int mm = yyyyMM % 100;
    int yyyy = yyyyMM / 100;
    GregorianCalendar d = new GregorianCalendar(yyyy, mm - 1, dd);
    return d.getTime();
}

From source file:org.power.commons.lang.util.time.DateUtils.java

/**
 * ?java.util.Date/*  w w  w  . java2s.c  o  m*/
 *
 * @param year  int 
 * @param month int 
 * @param day   int 
 * @return Date java.util.Date
 */
public static Date getDate(int year, int month, int day) {
    GregorianCalendar d = new GregorianCalendar(year, month - 1, day);
    return d.getTime();
}

From source file:org.sonar.plugins.dbcleaner.period.PeriodsTest.java

@Test
public void getDateShouldReturnCurrentTimeMinusDesiredMonths() {
    Project project = new Project("myproject");
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("KEY", "2");
    project.setConfiguration(conf);//w  w w.ja  v a  2s. c  om

    Date date = Periods.getDate(conf, "KEY", "2");

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.add(GregorianCalendar.MONTH, -2);
    Date expectedDate = calendar.getTime();

    assertThat(date.getMonth(), is(expectedDate.getMonth()));
}

From source file:TextFileTest.java

/**
 * Reads employee data from a buffered reader
 * @param in the scanner/*  w w w  .  ja v  a2s. c  o  m*/
 */
public void readData(Scanner in) {
    String line = in.nextLine();
    String[] tokens = line.split("\\|");
    name = tokens[0];
    salary = Double.parseDouble(tokens[1]);
    int y = Integer.parseInt(tokens[2]);
    int m = Integer.parseInt(tokens[3]);
    int d = Integer.parseInt(tokens[4]);
    GregorianCalendar calendar = new GregorianCalendar(y, m - 1, d);
    hireDay = calendar.getTime();
}

From source file:org.getobjects.appserver.core.WOMessage.java

public static Date dateFromHttpFormattedString(final String _httpDate) {
    int dayOfMonth = Integer.parseInt(_httpDate.substring(5, 7));
    int year = Integer.parseInt(_httpDate.substring(12, 16));
    int hourOfDay = Integer.parseInt(_httpDate.substring(17, 19));
    int minute = Integer.parseInt(_httpDate.substring(20, 22));
    int second = Integer.parseInt(_httpDate.substring(23, 25));

    int monthOfYear;
    String monthName = _httpDate.substring(8, 11);
    for (monthOfYear = 0; monthOfYear < 12; monthOfYear++) {
        if (httpMonthNames[monthOfYear].equals(monthName))
            break;
    }/* www.j av  a  2  s. c  o  m*/
    String tzName = _httpDate.substring(26);
    TimeZone tz = tzName.equals("GMT") ? gmt : TimeZone.getTimeZone(tzName);

    GregorianCalendar cal = new GregorianCalendar();
    cal.set(year, monthOfYear, dayOfMonth, hourOfDay, minute, second);
    cal.setTimeZone(tz);
    return cal.getTime();
}

From source file:com.sammyun.util.DateUtil.java

/**
 * beginDatedatas,datas?0??datasdatas0??datas
 * // ww  w.  ja v  a2  s  .  c om
 * @param ?
 * @return 
 */
public static Date getDate(Date beginDate, int datas) {
    Calendar beginCal = Calendar.getInstance();
    beginCal.setTime(beginDate);
    GregorianCalendar calendar = new GregorianCalendar(beginCal.get(Calendar.YEAR),
            beginCal.get(Calendar.MONTH), beginCal.get(Calendar.DATE));
    calendar.add(GregorianCalendar.DATE, datas);
    String begin = new java.sql.Date(calendar.getTime().getTime()).toString();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date endDate = null;
    try {
        endDate = sdf.parse(begin);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return endDate;
}

From source file:org.power.commons.lang.util.time.DateUtils.java

/**
 * ?java.util.Date//from  w w w .  ja va  2s  . c o m
 *
 * @param year  int 
 * @param month int 
 * @param day   int 
 * @param hour  int ?
 * @return Date java.util.Date
 */
public static Date getDate(int year, int month, int day, int hour) {
    GregorianCalendar d = new GregorianCalendar(year, month - 1, day, hour, 0);
    return d.getTime();
}