Hi I'm new to Java, I'm trying to convert standard time to Unix time so I can use that data in Max/MSP (to modulate a tone) eventually I will allow this program to take a text file of ordinary times and write to a text file the converted Unix times but I've currently run into a problem, it all works fine but it seems to be off by an hour.
To test I tried converting the time 2010-10-26 10:25:33 and I got 1288049133.
Here is my code:
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class timeToUnix2 {
public static void main(String[] args) {
String pattern = "yyyy-MM-dd hh:mm:ss";
SimpleDateFormat format = new SimpleDateFormat(pattern);
try
{
Date now = format.parse("2010-10-26 10:25:33Z");
long nowLong = now.getTime()/1000;
System.out.println("Value is " + nowLong);
}
catch (ParseException e)
{
e.printStackTrace();
}
}
}
Please excuse the way I write code, I'm sure there is a more efficient way to do things but as I said I am learning.
Cheers.