Java SQL Time Create getYear(String dateTime)

Here you can find the source of getYear(String dateTime)

Description

get Year

License

Apache License

Declaration

@SuppressWarnings("static-access")
    public static int getYear(String dateTime) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.sql.Timestamp;

import java.text.SimpleDateFormat;

import java.util.Calendar;
import java.util.Date;

public class Main {
    @SuppressWarnings("static-access")
    public static int getYear(String dateTime) {
        Calendar c = Calendar.getInstance();
        c.setTime(getDateTime(dateTime));
        int year = c.get(c.YEAR);
        return year;
    }//from w  ww.j a va 2  s  . co  m

    public static Timestamp getDateTime() {
        return Timestamp.valueOf(getFormatDate("yyyy-MM-dd HH:mm:ss"));
    }

    public static Timestamp getDateTime(String datetime) {
        return Timestamp.valueOf(datetime);
    }

    protected static String getFormatDate(String formatString) {
        String currentDate = "";
        SimpleDateFormat format1 = new SimpleDateFormat(formatString);
        currentDate = format1.format(new Date());
        return currentDate;
    }
}

Related

  1. getTimeZone(String timezone, String time, DateFormat format)
  2. getTodayAndTime()
  3. getTomorrowOrderTime()
  4. getUserToServerDateTime(TimeZone timeZone, int dateFormat, int timeFormat, String date, Locale locale)
  5. getWaitTimeout(Connection con)
  6. getYear(String dateTime)
  7. substract(Time thisDeparture, Time firstDeparture)
  8. SumTime(Time t1, Time t2)
  9. sumTimes(String[] timeStrings, DateFormat df)