Java Timestamp Create getTimestamp()

Here you can find the source of getTimestamp()

Description

get Timestamp

License

Open Source License

Declaration

public static String getTimestamp() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static String getTimestamp() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
        format.setTimeZone(TimeZone.getTimeZone("UTC"));

        Calendar c = Calendar.getInstance();
        TimeZone z = c.getTimeZone();
        int offset = z.getRawOffset();
        if (z.inDaylightTime(date)) {
            offset = offset + z.getDSTSavings();
        }//w w  w.j  av a  2s .  c o m
        int offsetHrs = offset / 1000 / 60 / 60;

        DecimalFormat formatter = new DecimalFormat("00");
        return (format.format(date) + "+" + formatter.format(offsetHrs) + ":00");
    }
}

Related

  1. getTimeStamp()
  2. getTimeStamp()
  3. getTimestamp()
  4. getTimestamp()
  5. getTimestamp()
  6. getTimestamp(Calendar time)
  7. getTimeStamp(Date date)
  8. getTimeStamp(Date date)
  9. getTimeStamp(Date date)