public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String time = in.next();

    // Set format for input and output
    SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ssa");
    SimpleDateFormat out = new SimpleDateFormat("HH:mm:ss");

    try {
      Date inTime = sdf.parse(time);
      System.out.println(out.format(inTime));
    } catch (ParseException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 2
0
  public String getId(Connection con) throws Exception {
    String ret = null;
    String sql = "select seq_id.nextval from dual";
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery(sql);
    if (rs.next()) {

      ret = sdf2.format(new java.util.Date()) + rs.getString(1);

    } else {
      throw new Exception("fail get id from oracle seq_id");
    }
    rs.close();
    st.close();

    return ret;
  }
Esempio n. 3
0
File: Macro.java Progetto: bramk/bnd
  public String _tstamp(String args[]) {
    String format = "yyyyMMddHHmm";
    long now = System.currentTimeMillis();
    TimeZone tz = TimeZone.getTimeZone("UTC");

    if (args.length > 1) {
      format = args[1];
    }
    if (args.length > 2) {
      tz = TimeZone.getTimeZone(args[2]);
    }
    if (args.length > 3) {
      now = Long.parseLong(args[3]);
    }
    if (args.length > 4) {
      domain.warning("Too many arguments for tstamp: " + Arrays.toString(args));
    }

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    sdf.setTimeZone(tz);

    return sdf.format(new Date(now));
  }
Esempio n. 4
0
 private String formatDate(Date myDate) {
   String strFormat = "yyyy-MM-dd HH:mm:ss";
   SimpleDateFormat formatter = new SimpleDateFormat(strFormat);
   String strDate = formatter.format(myDate);
   return strDate;
 }